Working on total ordering
Fix total ordering implementation.