Sorting content data

When and where, not how

Michael Czolko
50 Shades of Programming
2 min readMar 8, 2014

--

Sorting is important, we're trying to show user most valuable data. Visitor can read crappy texts after he scrolls down!

What is the problem

In most cases I've seen sorting on client side (web app, mobile app). Which I found as a very bad solution. This article is dedicated to sort data before you send them to client.

Hey, I have just one application, so, I don't care

Maybe. But still. Keep reading.

Example problem

Imagine, that we have a magazine of cars. On each page are shown data about certain car, for example: horsepowers, fuel consumption, pressure in tires and capacity of fuel tank. Definitely should be horsepowers and fuel consumption information on top.

Client sorting

When your server send data and client app will reorganize them, somebody can be confused. Data looks inconsistent. Then you must go to into project and look in which block of code this “feature” is. You rather spend time on something useful.

2 devices - mobile and computer

If we don't share code on both devices (most cases). We're now duplicate code functionality on both devices, which slows down rendering and they need some performance to do that.

Do server side sorting instead

Servers responsibility is keep and send data. Sort data before you send data to client side. Server have more performance to do this action. Or you can sort data before you store them into database - this is just a dream. Client is responsible for one thing - showing the data. It will be much easier for you, when you want to show pressure in tire information at the top. Change few lines of code on server code and your client applications doesn't have to be build and released.

Email feature

If you have button on the page which says: “Send me this information by email”. This is the point when you certainly need sorting on server side. Put code on right place, and you can delete this logic on clients.

--

--

Michael Czolko
50 Shades of Programming

I'm doing tappity tappity into the computer where code is the outcome.