[David Mertz] >> As me and Uncle Timmy have pointed out, it IS FIXED in sorted(). You just >> need to call: >> >> sorted_stuff = sorted(stuff, key=nan_aware_transform)
[Christopher Barker] > But what would that be? floats have inf and -inf -- so how could you force > the NaNs to be at the end or beginning? ... Python floats are encoded in 64 bits, but a key function can return anything at all - it doesn't have to return a float. David gave an example that returned a tuple, and I pointed to a msg in a bug report that returned a signed 64-bit integer implementing the relatively recent IEEE "total_order" function: https://bugs.python.org/msg336487 although that last moves all "negative" NaNs "to the far left" and all "positive" NaNs "to the far right". _______________________________________________ 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/SIURSMM6W5BIGUIZ2NJS5VB6DRADF7MI/ Code of Conduct: http://python.org/psf/codeofconduct/