how can we do sorting in Map in Java ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

how can we do sorting in Map in Java ??

9th Apr 2018, 3:32 PM
Mohit Aggarwal
Mohit Aggarwal - avatar
3 Answers
+ 9
Additionally to Boem Shakalaka 's answer you could: 1. Use a sorted map/tree map 2. Stream the map and sort it by using a comparator (if you want to define your own order and not the natural order that is implemented in the api) Note that a hashmap is defined as unordered.
9th Apr 2018, 9:14 PM
Tashi N
Tashi N - avatar
+ 1
https://code.sololearn.com/ctkvfjd6P3z0/?ref=app study this code
9th Jun 2018, 7:46 PM
Codebeast**
Codebeast** - avatar