Bill Baxter Wrote: In C++ code solution may looks like: template<class T>int compare(const T& lv,const T& rv) { return lv<rv?-1: rv<lv?+1: 0; } and using it like this struct S { int a,b; static int cmp(const S& lv,const S& rv) { int t=compare(lv.a,rv.a); if (t) return t; return compare(lv.b,rv.b); } }; any case it will requires from me only operator<