Originally posted by AnilPrakash Raju: I got a list of raw data which is ordered properly, and a comparator which has a list of code is sorted against.
when i run this I get a result that: it is sorted against the code properly( which i want) but within each code sorted, the list is not ordered properly.
The sort will sort only to the comparisons defined by the Comparator you define. If your comparator sorts on codes and not to any value within the code group, then the result list will be sorted by code only.
For example, if I had a list of names that were comprised of First Name, Last Name fields, and my Comparator sorted by Last Name:
In this case, since I am ordering by Last Name only then there would be no guarantee that Adam Luke would come before Steven Luke. Both have the same Last Name so they are equal as far as your sort is concerned.
To fix this, I would have to modify the Comparator to first compare Last Names, and if the result of the comparison was 0 (they are equal) then compare First Names and return the result of that.
You will have to do something similar with your program. First compare codes, and if the codes are equal compare again by whatever parameter sorts within the code.
It will give me the powers of the gods. Not bad for a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth