Created
July 9, 2020 20:09
-
-
Save JosephineAkello/9f884bead9ad226e8e7f15ed2177dbb8 to your computer and use it in GitHub Desktop.
Snippet to sort a hashmap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sort By Key | |
List<Employees> employee = new ArrayList<>(map.keySet()); | |
Collections.sort(employee); | |
Output -> [Anne, George, John, Mooh] | |
Sort by Value | |
List<Employee> employeeId = new ArrayList<>(map.values(); | |
Collections.sort(employeeId); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment