The correct answer, as others have pointed out, is to find out what a "strict weak order" is. In particular, if comp(x,y)true, then it comp(y,x)must be false. (Note that this means it comp(x,x)is false.)
This is all you need to know to fix your problem. The algorithm sortdoes not do promises at all if your comparison function breaks the rules.
, , sort, , quicksort . Quicksort " " . , a, b " ", , b, a " ", .