tag:blogger.com,1999:blog-5013829528944984059.post1849814780908529980..comments2024-03-28T22:50:54.940-07:00Comments on Open Source For Geeks: How to sort a Map on the values in Java?Aniket Thakurhttp://www.blogger.com/profile/07553743551249736583noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5013829528944984059.post-24336353308237618552017-06-05T07:59:46.734-07:002017-06-05T07:59:46.734-07:00Hi Nitin,
If you see the sortedMap declaratio...Hi Nitin,<br /> If you see the sortedMap declaration it is -<br />Map sortedMap = new LinkedHashMap();<br /><br />Since it is a LinkedHashMap it will maintain order.<br />Aniket Thakurhttps://www.blogger.com/profile/07553743551249736583noreply@blogger.comtag:blogger.com,1999:blog-5013829528944984059.post-24765378512409424882017-06-05T05:16:53.413-07:002017-06-05T05:16:53.413-07:00Here you sorted the list. Thereafter inserted the ...Here you sorted the list. Thereafter inserted the sorted list values one by one inside the hashmap. Hashmap does not maintain the insertion order, so how the order of elements be maintained ?Nitinhttps://www.blogger.com/profile/10038427389035232682noreply@blogger.com