I have a class for example Person.
public class Person {
private Integer age;
private String firstName;
private String lastName;
// getters and setters
}
I want to sort this in the ORDER BY style, which is provided by SQL queries. Collections.sort(listOfPersons, ) should return me data in this fashion.
“SELECT * FROM PERSONS ORDER BY AGE, FIRSTNAME, LASTNAME;”
Implement your own
Comparatorwould do, like: