Simon Fell > Its just code
Back to IComparer.Compare, I'd prefer it if it was
public bool Compare ( object a, object b )
returns true if a precedes b in a Strict Weak Order.
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 )
return -1;
if ( r < l )
return 1;
return 0 ;
}