mike's web log

 

Blog Search


(Supports AND)

 

Google Ads

 

Technorati

 

Feed

Subscribe to the RSS feed for this blog.

See this post for info on full versus truncated feeds.

 

Quote

I don't believe any more than Spinoza did in the utility of denouncing vice, evil, and sin. Why always accuse, why always condemn? That's a sad ethics indeed, for a sad people.

— André Comte-Sponville



 

Navigation






<September 2010>
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789


 

25 Most-Visited Entries

 

Categories

  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
 

Blogs I Read

 

Contact

Email me
 

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 8/26/2010

Totals
Posts - 2109
Comments - 2170
Hits - 1,138,425

Averages
Entries/day - 0.80
Comments/entry - 1.03
Hits/day - 434

Update every 30 minutes. Last: 6:46 PM Pacific

 
   |  ICompare.Compare values

posted at 05:22 PM | | [3] |

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 ValueValue Condition
Less than zeroa is less than b
Zeroa equals b
Greater than zeroa 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.

[1] I was going to email Chris directly, but I can't seem to track down an email address, including on his blog. Perhaps I'm just having a bad day, search wise.

[categories]