Pass an operator like a function
The le
operator is defined something like this :
sub infix:<le> { ... }
The infix:
prefix tells the language it's a infix operator. So if you want to call is as a sub its &infix:<le>(1,2)
or for your sort :
sort &infix:<le>, <4 6 2 9 1 5 11>;
(9 6 5 4 2 11 1)
This may help https://docs.raku.org/language/optut
Adding to Scimon's answer and in case you want a more "clear" presentation, you can use the following whatever construct:
sort *le*, <4 6 2 9 1 5 11>;
The previous code is a whatever construct (code object).
The whatever construct uses multiple * to generate blocks of code (anonymous subroutines) with as many arguments:
my $c = * + *; # same as -> $a, $b { $a + $b }
This means that the whatever sign (*) is used to denote the two (ore more) parameters that are used in the calculation
The same goes for our case:
sort *le*, <4 6 2 9 1 5 11>;
is the same as :
sort * le *, <4 6 2 9 1 5 11>; # adding space between operator and the whatever sign (*)
and this by turn is the same as :
sort -> $a, $b { $a le $b }, <4 6 2 9 1 5 11>; # anonymous subroutine
or
sort { $^a le $^b }, <4 6 2 9 1 5 11>;
or even
sub le {
$^a le $^b
}
sort &le, <4 6 2 9 1 5 11>;
References:
https://docs.raku.org/type/Whatever
https://docs.raku.org/type/Block