Tag: sorting

  • The different ways to sort Collections in Java

    Let’s say you have an Employee class with attributes like name , age , rating etc. You want to create a number of employees and sort them all by name. How to do this in Java? You make the Employee class implement Comparable interface which has a method compareTo(). The Employee class needs to implement…

  • How to handle pagination and sorting in Spring Data?

    Let’s say you want to handle pagination and sorting for your application and you don’t want to do the hard work of writing SQL queries or setting criteria using an ORM tool. Spring Data provides a very simple and efficient way to handle pagination and sorting. All you have to do is create a repository…