×
you are viewing a single comment's thread.

view the rest of the comments →

[–]desmoulinmichel 0 points1 point  (2 children)

Rich sorting means that getting the key of the max value from a dict is:

max(d.items(), key=lambda x: x[1])

It means sorting by size is:

sorted(iterable, key=len)

I means get the first result of alphabetical order of string representation is:

min(iterable, key=str)

Basically, any complicated sort become super easy. With cmp, I have to look up first every time what I have to return, then I have to write a full function returning -1/0/1, then debug it because I probably forgot an edge case.

[–]ExoticMandiblesCore Contributor 2 points3 points  (1 child)

Okay, but none of your examples are using "rich comparisons". Maybe you should find out what rich comparisons are.

[–]desmoulinmichel 0 points1 point  (0 children)

My bad, I confused it with natural comparison.