Here is a simple sorting program of an ArrayList:
ArrayList list = new ArrayList();
list.add(\"1_Update\");
list.add(\"11_Add\")
When you sort this type of data as a string, it is comparing the characters themselves, including the digits. All of the string that begin with "1", for example, will end up together. So the order ends up similar to this...
1 10 100 2 20 200
At no point does the sort "realize" that you are assigning meaning to subsets of the string, such as the variable length numbers at the front of the string. When sorting numbers as strings, padding to the left with zeros as much as required to cover the largest number can help, but it does not really solve the problem when you don't control the data, as in your example. In that case, the sort would be...
001 002 010 020 100 200
Because strings are sorted in a alphabetic ordering and the underscore character is after characters for numbers. You have to provide a comparator implementing "Natural Order" to achieve desired result.
As others have stated, the elements will be sorted alphabetically by default. The solution is define a concrete java.util.Comparator class and pass it as a second argument to the sort method. Your comparator will need to parse out the leading integers from the strings and compare them.
To have Collection.sort() sort arbitrarily you can use
Collections.sort(List list, Comparator c)
Then simply implement a Comparator that splits the string and sorts first based on the number and then on the rest or however you want it to sort.
Everyone has already pointed out that the explanation is that your strings are sorting as strings, and a number have already directed your attention to Natural Order string comparison. I'll just add that it's a great exercise to write that comparator yourself, and a great opportunity to practice test-driven development. I've used it to demonstrate TDD at Code Camp; slides & code are here.
It is sorted as text (alphabetically), not as numbers. To get around this you could implement a custom comparator as suggested in the answer by nsayer.