What is the best way to sort a field arbitrarily?
Example:
Each Content has a Status. Status‘s id is an enum. Business wants to see a list of Content sorted in the order Status.Id.REJECTED, Status.Id.IN_WORK and then Status.Id.PENDING.
As you can see, it’s not sorted alphabetically. And someone may change their mind and want it sorted differently or throw some more status’ in.
What is the best way to handle this situation? The only solutions I can come up with are adding an order to Status or to separately query each Status and then programatically stitch it together. But that seems dirty.
I understand there is some inherit absurdity with this premise but it is not mine and I have no control over it. Any help is greatly appreciated.
In the end I found the cleanest way to be to add an
intstatus.orderand then order the status’ by that column. This provided me with:The last point ended up being the real seller for me since the business side has a habit of incompletely thinking through their requirements and needing to change them several times during development and after launch.