I have a dataset like this:
water, 5
eggs, 3
juice, 7
bread, 4
i save all of these in
HashMap<String, Integer> dataSet = new LinkedHashMap<String,Integer>();
Now i want to create a function to print the elements from max integer to min:
juice, 7
water, 5
bread, 4
eggs, 3
i think that the easiest way to do this is to create a copy of HashMap dataSet and then i must run the HashMapCopy, find the max, print the max element and the remove it from the list.
private static void printMaxToMin(){
dataSetCopy = new LinkedHashMap<String,Integer>(dataSet);
}
How can i run all the list, find the max, print the pair of elements with the max value every time and then delete it?