I have a class
public class StudentVO {
int age;
String name;
}
I used the same class in two different areas. At one place i need t
You can cascade the comparators with thenComparing:
List files = new ArrayList();
Collections.sort(files,
new Comparator() {
public int compare(File file1, File file2) {
return file2.getName()
.compareTo(file1.getName());
}
}.thenComparing(
new Comparator() {
public int compare(File file1, File file2) {
return Long.valueOf(file2.getPath().length())
.compareTo(Long.valueOf(file1.getPath().length()));
}
}
)
);
// Collections.reverse(list);
https://www.eovao.com/en/a/sort%20elements%20java/4/how-to-sort-objects-in-java---multiple-comparison-sort-list