As others say, itβs good practice to sort the data in the database itself, and you can group by different criteria and for each group, which you can also sort. It also uses indexes, which can be considered one of the performance benefits provided that you index the database well.
Having said that, you cannot return all rows and use custom paging along with the necessary filter criteria, which does not return any rows that you selected for paging, and the total number of results found. This will definitely increase productivity.
source share