0

I'm having two fields, distance and id.

The distance value calculated from current position(GPS). The id value is either 1 or 0.

I want to sort based on distance and then the id. i.e. The value with lowest distance from current position and id = 1 should come first and goes on, then lowest distance and id = 0 should follow on.

Thank you all for the answers, sorting works now.

Madhan
  • 26
  • 3
  • 1
    What have you tried already? We can help you solve problems with your code, but we won't write it for you. Please include a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Robin Topper Apr 18 '17 at 07:36
  • Show us what have you tried !! – Basil Battikhi Apr 18 '17 at 07:36
  • 1
    This link will help you http://stackoverflow.com/questions/4805606/how-to-sort-by-two-fields-in-java – Pooja Arora Apr 18 '17 at 07:38
  • Your question doesn't really show what you need. But if you just need a hint : java `Collections` can sort themselves if they group objects implementing `Comparable`, if you can have your class implement `Comparable`, it's pretty much done. If you can't, you have to implement your own `Comparator` – Jeremy Grand Apr 18 '17 at 07:39

0 Answers0