I have a List<string>, where the entries are locations, like "010101", "010102", "010201", ..., with following meaning:
- First two characters : floor
- Next two characters : lane
- Last two characters : entry in lane
Normal sorting reveals a list like the following:
010101
010102
010103
010201
010202
020101
020102
020201
020202
020203
020204
...
I would like a custom sorting, where:
on floor "01", the sorting is done in a normal way:
010101 010102 010103 010201 010202on floor "02", the sorting is done in a reversed way for the lane, but not for the entry in lane, so something like:
... 020201 020202 020203 020204 020101 020102
Here on the site, I've found the IEnumerable as a solution, but this only works for List<T> where T is a new class. This is not relevant here, as I'm dealing with "simple" strings.
I've also found the Enumerable as a solution, but this also doesn't work, because the list of possible strings is far too large (not enumerable) and I'd prefer a flexible solution.
Does anybody have an idea?
Thanks in advance
There are multiple ways to achieve the desired behavior, e.g. using a
Comparison<string>: