- or download this
# cmp. Generic, "smart" three-way comparator.
...
# Compares strings with string semantics, numbers with number semantic
+s, Pair objects first by key and then by value etc.
# if $a eqv $b, then $a cmp $b always returns Order::Same. Otherwise O
+rder::Less or Order::More.
- or download this
dd 'a ä b'.comb.sort;
(" ", " ", "a", "b", "ä").Seq;
- or download this
subset CzechString of String;
multi sub infix:<cmp>(CzechString $a, CzechString $b) {
# sort logic here
}
- or download this
sub czech-sort(String $a, String $b) {
# sort logic here
}
@czech-words.sort( &czech-sort );
- or download this
dd ([1,'z'], [2,'a'], ['1', 'a']).sort( *.[0,1] );
(["1", "a"], [1, "z"], [2, "a"]).Seq
dd ([1,'z'], [2,'a'], ['1', 'a']).sort( { $^a[0] <=> $^b[0] || $^a[1]
+cmp $^b[1] });