Help for this page

Select Code to Download


  1. or download this
    my @xx = ( 'dfb|cy|nmju', 'dfb|my|jhiho', 'aaa|zz|gggg' );
    
    ...
    
    my @sorted_xx = map { $_->[1] } sort {$a->[0] cmp $b->[0]}
                    map { [ (split /\|/, $_)[$sort_field], $_ ] } @xx;
    
  2. or download this
    sub sorter {
        my @arr_a = split /\|/, $a;
        my @arr_b = split /\|/, $b;
        return $arr_a[$sort_field] cmp $arr_b[$sort_field];
    }