These numbers are stored in the same integer variable. How would I go about sorting the integers in order lowest to highest?
11367 11358 11421 11530 11491 11218 11
You can put them into a list and then sort them using their natural ordering, like so:
final List list = Arrays.asList(11367, 11358, 11421, 11530, 11491, 11218, 11789);
Collections.sort( list );
// Use the sorted list
If the numbers are stored in the same variable, then you'll have to somehow put them into a List
and then call sort
, like so:
final List list = new ArrayList();
list.add( myVariable );
// Change myVariable to another number...
list.add( myVariable );
// etc...
Collections.sort( list );
// Use the sorted list