Help for this page

Select Code to Download


  1. or download this
    use v5.16;
    my @sorted = (sub {
    ...
        push @{ $_ < $pivot ? \@small : \@big }, $_ for @_;
        return (__SUB__->(@small), $pivot, __SUB__->(@big))
    })->(@unsorted);
    
  2. or download this
    use v5.16;
    use List::MoreUtils 'part';
    ...
        my ($small, $big) = part { $_ > $pivot } @_;
        return (__SUB__->(@$small), $pivot, __SUB__->(@$big))
    })->(@unsorted);
    
  3. or download this
    my @sorted = do { my $SUB; $SUB = sub {
        return @_ unless @_ > 1;
    ...
        push @{ $_ < $pivot ? \@small : \@big }, $_ for @_;
        return ($SUB->(@small), $pivot, $SUB->(@big))
    }}->(@array);