Comment on Perl6: Unary SortparentComments−_ZeD_12yThey resolve differenti problems: say you have a list of complex object, and you wanna sort by an attribute, you can use mylist.sort(key=lambda element: element.attribute) Elsewere, say you want to sort a non-omogeneous list, or according to a custom order (attribute1 descending, attribute2 ascending) cmp make this easy−philh12yI think ve was saying, ve doesn't see the difference between python's `sort(key=...)` and perl6's `sort { one-arg block }`. (At any rate, I don't see that difference.)−rmc12yElsewere, say you want to sort a non-omogeneous list, or according to a custom order (attribute1 descending, attribute2 ascending) cmp make this easyYou can do this in python with the key function returning a list/tuple: mylist.sort(key=lambda element: (element.attribute1, -element.attribute2))−_ZeD_12yI'm not sure you can do -"string" :)
Comments
They resolve differenti problems: say you have a list of complex object, and you wanna sort by an attribute, you can use
Elsewere, say you want to sort a non-omogeneous list, or according to a custom order (attribute1 descending, attribute2 ascending) cmp make this easyI think ve was saying, ve doesn't see the difference between python's `sort(key=...)` and perl6's `sort { one-arg block }`. (At any rate, I don't see that difference.)
Elsewere, say you want to sort a non-omogeneous list, or according to a custom order (attribute1 descending, attribute2 ascending) cmp make this easy
You can do this in python with the key function returning a list/tuple:
I'm not sure you can do -"string" :)