Total ordering implementation