If you work in software development, you will see certain bugs in every year of your career. I recently wrote about numbers that aren’t numbers, and this article describes another one: unsorted lists.
Nobody expects an unsorted list
Imagine looking at a list of names - documents, people, or whatever - and you can’t work out how the list sorts its entries. Either you regularly examine detailed software functionality (because you test it), or you can’t find the list item you want, and have started wondering why not.
Sometimes, you can’t find the item you want in a list because the software did not sort the list items, leaving the list unsorted. You just found a bug, and not for the last time, because in general:
Unsorted is never the right order
Fortunately, you can fix this with minimal effort, unless you have problems of some kind. You certainly shouldn’t have to discuss it.
Don’t dwell on whether to call an unsorted list a bug
Your team’s definitions of bug and improvement don’t matter here. Software developers shouldn’t assume that they don’t have to sort a list, if nobody said otherwise. Meanwhile, product owners shouldn’t assume that everyone thinks the list has the same natural ordering, if you’ve never mentioned it.
If you don’t write down software specifications, even as user story acceptance criteria, you should still specify something as unusual as an unsorted list.
Sort lists alphabetically by display value, by default
This bug doesn’t happen when product owners and software developers have effective conversations. Either can say ‘the software will sort the list alphabetically’, and check that the other nods. Anything else belongs to a special case.
Note that this applies to both user interfaces and APIs. If you really want to leave an API result collection’s order as unspecified or unsorted, you need to account for some API consumers eventually relying on all API behaviour, specified or not.
Unsorted items don’t necessarily appear in random order. If you don’t explicitly sort a list, the underlying technology stack may give you items in creation order, for example. If you really want to represent something as an unsorted set, you may have to explicitly randomise it so that API consumers can’t rely on its accidental ordering.
Make the order explicit, including direction
Most collections have a natural ordering, usually alphabetical order for a list of names. If you sort a list any other way, such as popularity or relevance, you need to explicitly state the order to avoid a user experience of apparently random order.
For numeric and date values, specify the direction as well. Phrases like low to high and newest first seem to resolve the ambiguity that ascending and descending can suffer from.
Show the values you sort by
If you do sort a list of documents by date modified, then it’s probably worth actually showing that date. In general, display the value you sort by. In the same way that your new product doesn’t actually have to repeat the classic unsorted list bug, your user interface doesn’t have to reinvent the user experience from first principles.