I have searched a lot for two days and i was not successful ,
Now i have strings with 7 integer numbers ( both + and - ) separated with comma .
I have written a sample code to explain .
ArrayList<String> str = new ArrayList<String>();
str.add("9,-9,21,23,28,29,35");
str.add("18,18,-21,28,28,32,34");
str.add("-11,-11,22,28,29,-30,31");
str.add("8,-8,26,31,31,31,31");
str.add("8,8,26,-32,25,29,35");
str.add("10,9,-21,45,25,29,35");
str.add("-11,59,21,25,25,-29,35");
str.add("12,-9,21,55,25,29,15");
str.add("9,9,21,25,25,-29,35");
str.add("7,9,21,25,-35,25,35");
str.add("4,-39,21,-15,25,-29,35");
str.add("9,9,21,25,27,29,-35");
str.add("10,9,21,35,25,39,15");
str.add("8,-9,21,-25,25,29,-35");
str.add("18,-9,21,-23,25,29,-35");
Collections.sort(str);
this does not return the correct sorted array . It tests with the first digit of the numbers and proceed with the sorting .
But what i want is , the sorting must be based on the first numbers in the string . Only if the numbers are same ( say there are three 9 in the first numbers of string arrays ), it should check for the second numbers in those(tied strings alone) and sort accordingly and so on .
the result should be as
9 , -9 , 21 , 23 , 28 , 29 , 35
9 , 9 , 21 , 25 , 25 , -29 , 35
9 , 9 , 21 , 25 , 27 , 29 , -35
Is there any method to sort in this method . Please let me know if any , any related answers are welcomed .
Thanks in advance .