IMHO, another sorted function, slower than it, should be added. I don't know exactly how timsort works, but I know that it requires only `__lt__()`.
So probably it checks, element by element, if `elem_b < elem_a`, and probably exchange them if this is `1`. If `0`, it does nothing. (Yes, `0` and `1`, I'm thinking about CPython). I think that a `sorted_slow()` function should also check, if `elem_a < elem_b == 0`, what `elem_a < elem_b` gives. If also this check returns `0`, there are two cases: 1. the objects are equal 2. elem_a (or also elem_b) are not orderable In this case, there's no problem: the function will switch `elem_a` and `elem_b`. If they are equal, it changes nothing. If `elem_a` is unorderable, this way at the end of the algorithm, `elem_a` will be at the end of the iterable. This is also good for the programmer, because (s)he can slice the NaNs away more easily, if (s)he wants :) I think Java do the things this way, because I tested `Collections.sort()` with a List<Double> and it puts all NaNs at the end of the list. _______________________________________________ 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/7255SH6LSC266HAGI4SRJGV4JTUMMI4J/ Code of Conduct: http://python.org/psf/codeofconduct/