I have studied the questions that are about sorting the map, most of those are sorting thap with single key and single values and most of those don't have unique value. Like this question.
I am grouping the list based on the teacherID.
Map<String, List<Assignmentsdata>> result = liveAssignments.stream().collect(Collectors.groupingBy(Assignmentsdata::getTeacherId));
Now students see the assignments added by teachers in the form of groups. but now I want to sort those groups based on the variable totalCompletedAssignments. And now I am lost on how to sort the above map, and at the same time, I don't want multiple loops. Like If a students have not done one assignment at all from teacherA, its place is on top.
Current Output: At index 0 -->TeacherA[(Assignment1->Progress = 10) (Assignment2-> progress 2)] At index 1--> TeacherB[(Assignment1->Progress = 10) (Assignment2-> progress 0)]
Since TeacherB group have an assignment that has 0 progress so far, so it is expected to be at first index like this
Expected OutPut:At index 0--> TeacherB[(Assignment1->Progress = 10) (Assignment2-> progress 0)] At index 1 -->TeacherA[(Assignment1->Progress = 10) (Assignment2-> progress 2)]