Simon Fell > Its just code
A number of people have asked why I don't like IComparer.Compare. What I don't like is that I have to implement tests for <, = and >. STL uses Strict Weak Ordering which only requires a < operator (or a binary predicate equivilent). This has nothing to do with STL's use of templates, and in fact the implementation of IComparer.Compare I wrote only needs a < operator for the type it delegates to.
public int Compare ( object a, object b )
DateTime l = ((sample)a).date ;
DateTime r = ((sample)b).date ;
if ( l < r )
if ( r < l )
return 0 ;