Hello i need one help i am thinking to store values in (key,pair) where key is a double array of 4 values. finaly I have to sort this list based on double value (key) if i find more then one key i have to store those values say ex (a,1) (b,2) (a,2) (c,1) In tis case i am looking for sorted list to have only (a,1) & (a,2). ANy help appreciated
You can use a TreeMap with a custom Comparator to sort based on the double value in the key. Then, remove duplicate keys by using a HashSet to store unique keys. Finally, convert the TreeMap keys back to the desired (key, pair) format.