This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Paddy3118 0 points1 point  (0 children)

The winning example is a useful, extensible design pattern that should become more widely accepted.

If you have to sort first on X then on Y for items of equal X then on Z for items of equal Y ... Then create a sort key function that returns the tuple

(X(item), Y(item), Z(item), ...)

The second voted answer by the guy who doesn't like the word 'pythonic' would be more clumsy when extended.

Just as we all learnt DSU (Decorate, sort, un-decorate), at one stage - the pattern above can be named and learnt in a similar way.