1

I'm currently tasked with implementing client side sorting on specific page view for our application.

Below is an example of how the UI for client side sorting works, basically a user can click on a desired table header so results are sorted in ascending or descending order (using JavaScript). This example is static, but hopefully it conveys a clear idea of how the solution looks and functions.

name progress ⬇︎ created accessed
Bob 95% 02/23/2021 05/02/2021
Alice 45% 04/12/2021 06/22/2021
John 23% 05/25/2021 03/12/2021

After working on the pull request, one of the developers pointed out that this feature seems unnecessary because the endpoint that brings in the results is paginated, and for this reason, it makes no sense to have client side sorting. The justification was that "It gives obviously false sorting because you don't sort the full dataset".

I thought about this and I'm inclined to disagree with that statement; as a user, it makes sense to have the ability to sort paginated results to find what you're looking for without having the entire set of results. Is my assessment correct?

1 Answer 1

2

I think you are misunderstanding what the developer is trying to tell you.

They are not saying you need to provide the full data set to the user, but that you need to apply the sorting before the pagination is applied. This is absolutely correct, and you should not support client-side sorting if you have paginated data - it will be incorrect and misleading.

As a quick example. Lets say you have the following data set:

  • Apple
  • Blackberry
  • Cranberry
  • Dragonfruit
  • Elderberry
  • Fig

Now lets say your pagination is 5 results per page, and you apply sorting, descending (Z-A).

If you do that sorting client-side, you will get: Elderberry, Dragonfruit, Cranberry, Blackberry, Apple. Which is wrong, because fig should be first.

If you sort server-side, before you apply pagination, you will correctly get: Fig, Elderberry, Dragonfruit, Cranberry, Blackberry. Where Apple will then be on the second page.

1
  • Thanks for the insight, that was helpful.
    – Juan Marco
    Jul 27, 2021 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.