Showing results for October 23, 2003 - The Old New Thing

Oct 23, 2003
Post comments count0
Post likes count0

Writing a sort comparison function

Raymond Chen
Raymond Chen

When you are writing a sort comparison function (say, to be passed to or *gasp* to be used as an ), your comparison function needs to follow these rules: Reflexivity: . Anti-Symmetry: has the opposite sign of , where 0 is considered to be its own opposite. Transitivity: If and , then . Here are some logical consequences of these rules (all ...

Code