Sorted out the __cmp__ function