On 3/9/20 12:41 AM, Steven D'Aprano wrote:
> Wait, no, that's not right either... each element doesn't compare less 
> than the previous element?
>
If the elements of the list don't form a total order, then sort makes NO
promises about the data returned, other than it is the input data in
some order. I suppose the last elements compared will be in order, but
it doesn't promise that for the rest of them. In particular, if a
comparison causes a swap, it doesn't go back and check that the
resulting new pairs are in order, unless the algorithm, based on the
assumption of total order, thinks it might need to.

-- 
Richard Damon
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/X7SNS3UDRKENL6HH5DKF42HM37UUSF3Z/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to