I have date in this format:
Key Value
13:00:08 : 3
13:00:08 : 2
13:00:08 : 2
13:00:06 : 2
13:00:08 : 2
13:00:09 : 1
13:00:07 : 2
13:00:09 : 3
I convert the timestamp to seconds. Then based on the timestamp, I have to sort the data.
I tried using TreeMap
but it removes duplicates. I tried HashMap
but it removes the duplicates. MultiMap
will not work here.
Code which I tried was :
Map<Integer, Integer> map = new TreeMap<Integer, Integer>(tmap);
System.out.println("After Sorting:");
Set set2 = map.entrySet();
Iterator iterator2 = set2.iterator();
while(iterator2.hasNext()) {
Map.Entry me2 = (Map.Entry)iterator2.next();
System.out.print(me2.getKey() + ": ");
System.out.println(me2.getValue());
}
How can I proceed with the sorting?