We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
@Override
public int compare(Student o1, Student o2) {
int compareName =o1.getFname().compareTo(o2.getFname());
int compareCgpa=Double.compare(o2.getCgpa(), o1.getCgpa());
int compareId=Integer.compare(o1.getId(), o2.getId());
return (compareCgpa==0)?(compareName==0)?compareId:compareName:compareCgpa;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Sort
You are viewing a single comment's thread. Return to all comments →
studentList.sort(new Comparator() {