I have following HashMap
"1":
{
"profilePic":null,
"roleNo" : "12"
},
"2":
{
"profilePic":null,
"roleNo" : "1"
}
I want the output as below
"2":
{
"profilePic":null,
"roleNo" : "1"
},
"1":
{
"profilePic":null,
"roleNo" : "12"
}
I have tried the below code but didn't get the output as expected
LinkedHashMap<Long, Person> newPerson = attendanceMap
.entrySet()
.stream()
.sorted(Map.Entry.comparingByValue(new AttendanceListComparator()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
My attendancelistcomparator is as below
@Override
public int compare(Person s1, Person s2) {
return sortingOrder*s1.getRoleno().compareTo(s2.getRoleno());
}
Please suggest me something to get the sorted data