on sorting things

Chris Angelico rosuav at gmail.com
Fri Dec 20 13:11:21 EST 2019


On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__peter__ at web.de> wrote:
> PS: If you are sorting files by size and checksum as part of a deduplication
> effort consider using dict-s instead:

Yeah, I'd agree if that's the purpose. But let's say the point is to
have a guaranteed-stable ordering of files that are primarily to be
sorted by file size - in order to ensure that two files are in the
same order every time you refresh the view, they get sorted by their
checksums.

There ARE good reasons to do weird things with sorting, and a custom
key object (either with cmp_to_key or directly implemented) can do
that.

ChrisA


More information about the Python-list mailing list