I need to filter and order data entries after criteria that a user selects through a dropdown. Selectable will be things like “newest entries first”, “oldest entries first”, “lowest price first” etc.
I could just create an enum for the options and switch/case where I retrieve the data, but I’d rather do this in an easily extendable way.
What design pattern would fit the situation best?
Everyone has mentioned the strategy pattern. Just thought I’d post my simple implementation. No need to make it more complicated than necessary.