Help for this page

Select Code to Download


  1. or download this
    use strict;
    my $foo = [ {blah=>'aaa'},{blah=>'ddd'},{blah=>'ccc'} ];
    ...
    my $sortfunc = sub { $a->{blah} cmp $b->{blah} };
    
    my @arr = sort $sortfunc @$foo;
    
  2. or download this
    my @arr = do {local *sortfunc = $sortfunc; sort sortfunc @$foo};