I need to sort every value of a Map with multiple objects in each value, but I am struggling to see how. My Map looks like this:
HashMap<String, List<Carrier>> carriers_list;
I already have a Custom Comparator set up to compare a List of my objects.
static class CarrierComparator implements Comparator<Carrier> {
@Override
public int compare(Carrier c1, Carrier c2) {
return c1.get_name().compareTo(c2.get_name());
}
}
I can use this Comparator like so:
List<Carrier> carrierList = getAllCarriers();
Collections.sort(carrierList, new CustomComparators.CarrierComparator());
How can I get each List for every key in my Map?