I have array of objects person (int age; String name;).
person (int age; String name;)
How can I sort this array alphabetically by name and then by age?
Which algorithm would
You can do like this:
List users = Lists.newArrayList( new User("Pedro", 12), new User("Maria", 10), new User("Rafael",12) ); users.sort( Comparator.comparing(User::getName).thenComparing(User::getAge) );