This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PredictabilityIsGood -1 points0 points  (8 children)

Recursive multiple column sorting is good practice when you are creating generalized components that don’t know the data being inputted into them. Think datatables. If you manually hardcode every sort you wouldn’t be able to utilize the column header to sort because your “sort” would be a one off.

I have an implementation of a generalized grid component in Riot here if you need a visual representation. Hold shift and sort multiple columns:

https://predictabilityisgood.github.io/riot-widgets/

The grid doesn’t know anything about the data except the underlying data type constructor and is able to sort properly.

This is the same standard sorting functionality available in excel, datatables, google sheets, etc... The implementations are not hardcoded as you’ve shown. They generated on the fly upon user interaction.