Update
I've found a better design for this. It has quite a few improvements:
- I use a
Dictionary
to speed up ordering look-ups
- By extracting this behaviour into a separate type, the dictionary can be cached and reused between multiple sorts
- The ordering-derivation is decoupled from sorting, so it could be used in more ways
- The
omitEntirely
responsibility was removed entirely. It should instead by done by a simple call to filter
, with hardcodedOrdering.contains
as the predicate.
See my new answer, here