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.