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 easyYou can do this in python with the key function returning a list/tuple:
mylist.sort(key=lambda element: (element.attribute1, -element.attribute2)) my $a = [2,1]; say $a.sort; say $a # 1 2 2 1
my $a = [2,1]; say $a.=sort; say $a # 1 2 1 2
This riffs off the general op= syntax: my $a = 1; say $a + 1; say $a # 2 1
my $a = 1; say $a += 1; say $a # 2 2