Return to Blog Home

Sorting based on Preferences

Source Live

Sorting based on Preferences

Efficiently sorting lists based on user preferences between items!

When users want to sort a list of items there aren't too many options they have, numerically, and alphabetically. Manually sorting a list can be both tedious and difficult for people to do as more items get added, this is where sorting by a users own preferences between two individual items solves both issues.

The Algorithim

The great thing about technology is that for the most part what you're looking to do has already been done by someone else, and if you're lucky in an easy way for you to use and change to match your desires.

In this case a StackOverflow answer is the base of what I'm using for my algorithim, converted to ES6.

In essence though, for an example list of 10 items, that can result in 45 questions between all items, but asking questions in the correct order for 10 items we can manage the same order by asking only 9 questions under the best case.

The App

While this could be frontend only, as the comparisons would need to be saved, it was implemented with authentication to allow users to save both their lists and the internal comparisons that generates the order of items, of course allowing anonymous usage with the option to import & export lists.

In addition various QOL features exist, from managing the previous comparisons, sharing the list with others, and editing all user values.