Sorthing house numbers of type string
Say you have a string property for house numbers (1, 98, 24b) and want to sort them. How can you sort them by number as well as by letter? If I just sort them with OrderBy I get 1, 138, 24 which isn't correct.
4 Replies
what you are looking for is natural sort order
I'd probably create my own
HouseNumber
struct or class, with Number
and Letter
properties
Then a custom comparer in itThanks, both suggestions seem plausible
i knew i had written natural sort at some point, found some old code