i am developing an app in which i get data from server and display in map. but before display it on map’s balloon i have just sort data by one field name is “Destination” and there are method made na,e is ..GOTOSORT….
now problem is i got variables s with length 1 and there for the for loop are run only 1 time , but there are 42 data are come from webservices so please check it and tell me what is the problem
private void GOTOSORT() {
Log.i(TAG, " SORT ");
Map<Float, Integer> map = new TreeMap<Float, Integer>();
for (int i = 0; i < lng_timeStamp.length; ++i) {
map.put((float) lng_timeStamp[i], i);
}
Collection<Integer> indices = map.values();
System.out.println("indices" + indices);
Integer s[] = (Integer[]) indices.toArray(new Integer[0]);
Log.i(TAG, "s.length"+s.length);
for (int i = 0, n = s.length; i < n; i++) {
System.out.println(s[i]);
int_sort_MyhourGetTime[i] = int_MyhourGetTime[s[i]];
int_sort_MyMinGetTime[i] = int_MyMinGetTime[s[i]];
lng_sor_timeStamp[i] = lng_timeStamp[s[i]];
arr_sort_ServiceNumber[i] = arr_ServiceNumber[s[i]];
arr_sort_Destination[i] = arr_Destination[s[i]];
}
If you want to sort your list , you should follow the Java’s comparatorFollow here
It will return you a sorted list in any order.
All the best !! 🙂