Help for this page

Select Code to Download


  1. or download this
    @sorted = sort {
      my @a = $a =~ /^(.+?)(\d+)#(\d+)$/;
      my @b = $b =~ /^(.+?)(\d+)#(\d+)$/;
      $a[1] <=> $b[1] or $a[2] <=> $b[2] or $a[0] cmp $b[0]
    } @unsorted;
    
  2. or download this
    @sorted =
      map { $_->[0] }
      sort { $a->[2] <=> $b->[2] or $a->[3] <=> $b->[3] or $a->[1] cmp $b-
    +>[1]
      map { [ $_, /^(.+?)(\d+)#(\d+)$/ ] }
      @unsorted;
    
  3. or download this
    use Sort::Fields;
    
    my $sorter = make_stable_fieldsort( '(\d+)#', [ '2n', '3n', '1' ] );
    
    my @sorted = $sorter->( @unsorted );  # voila