We have some columns in a grid that contain numbers, strings, or strings that start with a number and the users expect them to sort in a sensible way. (The format depends on the customer so we don’t know the formats the strings will be in)
Is there a pre-canned” implementation of IComparable that does something like this?
here is a fast alphanumeric sort (can be used for other sorts with numerics too).
C# Alphanumeric Sorting http://www.dotnetperls.com/alphanumeric-sorting
and here is a nice article about the problem:
Sorting for Humans : Natural Sort Order http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html
Here is the
AlphanumComparatorFastclass in case the above link stops working The end of the page states “It can be used in any program with no restrictions” and the comment at the start of the code also indicates it is free for use: