I have an ArrayList of Strings in Java. All strings have the format [Integer] [String]. For example:
100 Tom Dsa 
 23 John Asdf
 98 Mary Qwerty
I want to sort this ArrayList by the Integer. The correct output would be:
23 John Asdf 
 98 Mary Qwerty 
 100 Tom Dsa
Right now, I'm using the following code:
Collections.sort(obj);
The problem with it is that interprets the integer as a string, therefore 100 is sorted before 2.
Is there any way of sorting this correctly?