I'm just trying to see if there is an easy way to sort a list of String objects. Problem I'm facing right now is that the Collections.sort(...) method is not working for me.
This is my original list, which for my requirement purposes is sorted:
List<String> values = new ArrayList<String>();
values.add("section_1");
values.add("section_2");
values.add("section_3");
values.add("section_4");
values.add("section_5");
values.add("section_6");
values.add("section_7");
values.add("section_8");
values.add("section_9");
values.add("section_10");
values.add("section_11");
values.add("section_12");
values.add("section_13");
And after doing Collections.sort(values), the order is now broken:
section_1
section_10
section_11
section_12
section_13
section_2
section_3
section_4
section_5
section_6
section_7
section_8
section_9
Is this behavior because of the lexicographical ordering used in Collections.sort(...) ? Is there an easier way to make this sort work the way I want it to?
Thanks in advance.