Putting or sorting a list in order

I am stuck! I want to have my students take input (numbers) from a user and then store them in a list (easy), but display the list in order from smallest to greatest.
Any help or tips would be appreciated!
Thanks!

You could show them a simple sort algorithm like bubble sort or you can tell them about the sort method on Arrays. Which ever fits your curriculum.

Yep, what Don said.

In other words, if you’re wondering if there’s a built-in function to sort an array, there is not. But it’s a great opportunity to learn sorting algorithms (and as Don suggested, bubble sort is a good place to start).

App Lab does have a sort method on Arrays. [3,2,1].sort(); returns [1,2,3].

Oh whaaaaaat. Thank you for pointing that out. I stand corrected.

1 Like

If student use the Arrays[3,2,1] to be sorted in order, that needs to be cited? or can student use arrays in their code?