You are viewing a single comment's thread. Return to all comments →
To be honest, i have no idea why thats not working 😅
class Priorities { public List<Student> getStudents(List<String> events) { PriorityQueue<Student> response = new PriorityQueue<>( Comparator.comparing(Student::getCGPA, Comparator.reverseOrder()) .thenComparing(Student::getName) .thenComparing(Student::getID)); for (String event : events) { if (!event.contains("ENTER")) { response.poll(); continue; } String[] split = event.split(" "); Integer id = Integer.valueOf(split[3]); Double cgpa = Double.valueOf(split[2]); Student student = new Student(id, split[1], cgpa); response.add(student); } return response.stream().collect(Collectors.toList()); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Priority Queue
You are viewing a single comment's thread. Return to all comments →
To be honest, i have no idea why thats not working 😅