I would be inclined to define <code> int GenericItemCmp(...); </code> returning -1 for lhs < rhs, +1 for lhs > rhs else 0 for equality.