Wednesday, 19 December 2007
|
ICompare.Compare values
posted at
05:22 PM
|
trackback
|
|
link
Chris Wuestefeld took a crack at the "natural sorting" issue that Jeff Atwood stirred up last week. Chris presents a custom implementation of IComparer that he calls NaturalComparer.
Interesting stuff. (Uses RegEx, brave fellow.) In the article, Chris lists the three values that the Compare method should return: -1, 0, or 1. He then says this:you may want to note the above list; I was unable to find it explicitly spelled out anywhere else This sounded odd to me, coz that list of values sure looked familiar. (As it turns out, I knew this list from reading the docs for IComparable.CompareTo method.)
I'm not 100% sure where Chris's remark came from.[1] The docs for Comparer.Compare list this:
| Return Value | Value Condition | | Less than zero | a is less than b | | Zero | a equals b | | Greater than zero | a is greater than b |
Is that the same information? It looks like it to me. (?) Is it in the wrong place? If so, let me know so we can fix that.
[categories]
aspnet
|