Lets say we have a sortable table like this:


download bmml source – Wireframes created with Balsamiq Mockups

It seems obvious that if I click on "Employee", that the table should reorder itself, probably putting the checked at the top and unchecked at the bottom.

But what if the table looks like this:


download bmml source

What should happen if the user clicks "Employee"? A few possibilities:

  1. Do nothing
  2. Reverse the current order
  3. Order according to some "primary sort key" (in this example there is none -- or maybe it's the name?).

Also, don't focus on the fact that it's a column of checkboxes either, the same approach should apply if it was a column of numbers that were all "42" or a column of text that was all "Plumbing".

3 Answers 3


What should happen is that the sort mark is switched over to the Employee column and that it the row should be sorted according to ascending order of that column. Regardless of what the column currently holds.

This may or may not change the order of the rows depending on the "natural" order of the underlying information. The current sort order of the information should only be retained if that is what you would also try to achieve when sorting on a different column that does not have all identical values. For example when you sort people with the same age in alphabetical order of their names when the user clicks on the Age column.

Some underlying "primary key" or rather inherent natural order like people's names can always be added. But if you do that, you should add it to all other sorting orders (like age), so it will be the order for rows with identical values in the column that the user selected to sort on.

Most certainly the current order should not be reversed. That should only happen when you click on the column that already shows the sort mark.

  • Just a simple concise answer. Bravo.
    – Taj Moore
    May 17, 2012 at 18:21
  • I'm not sure I completely understand this answer. I see you're saying don't make this a special case, and in particular don't reverse the order (and I certainly agree with both of those points) but are you saying change the sorting to the "natural" order or not? (Or are you refraining from taking a position on that?) The entire concept of "natural" order seems problematic since so often any arbitrary choice of "natural" by the developer appears random to the user, as pointed out in Myrddin Emrys's answer.
    – Don Hatch
    May 6, 2014 at 9:31
  • @DonHatch What I am saying is that if the rows are currently sorted on name and you change the sort order to some fieldA, show the rows with identical values in fieldA in the order in which they occurred in the previous sort order (in this case Name). This would achieve "cumulative" sorting on multiple columns. If that is difficult to implement show the rows with identical values in field in the table's "primary" order. Either its primary key or - if that is a meaningless number - some field that people would naturally use to order something (eg Name/description, for people or things). May 6, 2014 at 11:12

This is dependant on how you implement sorting. In general, the previous sorting method is ignored when you click a new column. In the back end, only the most recent column is sorted.

Example: Click Age, then Name, then Employee
Result: ORDER BY Employee

However, there is a fancier way to implement sorting. This is where you retain the previous choices. Every sort request is added to the 'stack' of sorts. The most recent column has priority, but the other sorts are still being done as well, in order.

Example: Click Age, then Name, then Employee
Result: ORDER BY Employee, Name, Age

Clicking a column you have sorted on previously moves it to the top of the stack if it's already on the list. This requires some additional development effort, especially if you are depending on a tool to manage the sorting for you, but it does make issues like this more user friendly, because without this multi-column sorting, clicking the Employee column will result in random ordering (or ordering by primary key, which is probably random to the user); with multi-column sorting, the behavior is more consistent with user expectation.

  • I think this is a great answer, but the implication to the original question might not be crystal clear. Another simple way of describing your solution is: always do a stable sort; that is, leave items with equal key values in the same order they were in previously. So in particular, in the case described in the original question, the answer is "1) do nothing" (except do switch the sort mark over to the Employee column). I consider the multi-column sorting ability to be simply a (very useful) side effect of this natural way of doing it.
    – Don Hatch
    May 6, 2014 at 9:27

Do nothing. There is really no value to the user sorting on that column if the data is the same. If that is a common occurence for a given column, you may need to consider a different way of showing that data (a table may not be the best way to show that data).

For example, categorize the different rows, similar to this IBM documentation (Sorry, I can't post images yet, due to my reputation)

Your Answer

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

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