I have the following objects:
public class Shipping {
String name;
List methods;
}
public class Method {
String serviceType;
Strin
You need either a comparator or implement Comparable for Method class like:
public class Method implements Comparable {
public int compareTo(Method thatMethod) {
return Integer.compare(Integer.parseInt(this.cost), Integer.parseInt(thatMethod.getCost()));//if you need name then you could do this.cost.compareTo(thatMethod.getServiceType()); assuming serviceType can never be null
}
}
And then sort your list like:
Collections.sort(methods);