I want to sort a vector which contains Object of following fields
public class CategoryListing {
String company_id;
String company_name;
double distance;
//setters and getters here
}
I populated the vector from webservice, now I want to sort that vector by distance, means I want to show nearest one. How can I sort the vector which contains objects?
You can use Comparator.
Define a comparator which will sort on distance like below
Sort vector using
below sort method. Note As Arrays are present from 1.2 It is also present for blackberry.public static void sort(Vector vector,Comparator comparator) {