0👍
You need to do the sorting in the backend when you do pagination, basically, your API method should support a sorting parameter, sort the list according to that parameter, paginate the results after sorting and return paginated results.
Your client does not have access to all the data, so you can not do the sorting on the client side when there’s pagination, results need to be sorted before a slice is taken.
Source:stackexchange.com