Datastructures for storing sorted values

90 views Asked by At

My data is in the form of key value.i want to sort values.i have stored them in hashmap.

map.put(1,.8678)
map.put(2,.9578) map.put(6,.0453)

i want output:

(6,.0453), (1,.8678), (2,.9578)

I want to sort values, retrive sorted values and their keys efficient(with the least complexity).What is the best data structure for my problem? Thanks.

1

There are 1 answers

1
Thudani Hettimulla On

use a TreeMap instead of a hashmap