List-Rank

 view release on metacpan or  search on metacpan

lib/List/Rank.pm  view on Meta::CPAN

                $ary[$i-1][2] = $ary[$i][2] = "$j=";
            } else {
                $j = $i+1;
                $ary[$i][2] = $j;
            }
        }
    }
    map { $_->[2] } sort { $a->[1] <=> $b->[1] } @ary;
}

sub rankby(&;@) { ## no critic: Subroutines::ProhibitSubroutinePrototypes
    no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict

    my $cmp = shift;

    my $caller = caller();

    my @ary;
    my $i = 0;
    for (@_) { push @ary, [$_, $i++, undef] }
    @ary = sort {

lib/List/Rank.pm  view on Meta::CPAN

                $ary[$i-1][2] = $ary[$i][2] = "$j=";
            } else {
                $j = $i+1;
                $ary[$i][2] = $j;
            }
        }
    }
    map { ($_->[0], $_->[2]) } @ary;
}

sub sortrankby(&;@) { ## no critic: Subroutines::ProhibitSubroutinePrototypes
    no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict

    my $cmp = shift;

    my $caller = caller();

    my @ary;
    my $i = 0;
    for (@_) { push @ary, [$_, $i++, undef] }
    @ary = sort {



( run in 0.539 second using v1.01-cache-2.11-cpan-49f99fa48dc )