if i have a map like this:
Map<Fruit, Double> multiMap = new HashMap<Fruit, Double>();
is there a way for me to sort on the Double values while still keeping the Double values linked to the corresponding Fruit object?
initially i was thinking of doing something like this:
public ArrayList<Double> sortAllValues() {
ArrayList<Double> allEntries = new ArrayList<Double>();
for (Entry<Fruit, Double> entry : multiMap.entrySet())
allEntries.add(entry.getValue());
}
return Collections.sort(allEntries);
}
but if i do this i lose the linkage between the Fruit and the Double value... any ideas?
Thanks in advance