List::Rank - Ranking of list elements
This document describes version 0.002 of List::Rank (from Perl distribution List-Rank), released on 2018-01-26.
Return the ranks of the elements if sorted numerically (note that equal values will be given equal ranks):
my @ranks = rank 10, 30, 20, 20; # => 1, 4, "2=", "2="
Return the ranks of the elements if sorted ascibetically:
my @ranks = rankstr "apricot", "cucumber", "banana", "banana"; # => 1,4,"2=","2="
Return the ranks of the elements if sorted by a custom sorter:
my @ranks = rankby {length($a) <=> length($b)} "apricot", "cucumber", "banana", "banana"; # => 3, 4, "1=", "1="
Sort the list numerically and return the elements as well as ranks in pairs:
my @res = sortrank 10, 30, 20, 20; => 10,1, 20,"2=", 20,"2=", 30,4
Sort the list ascibetically and return the elements as well as ranks in pairs:
my @res = sortrankstr "apricot", "cucumber", "banana", "banana"; # => "apricot",1, "banana","2=", "banana","2=", "cucumber",4
Sort the list by a custom sorter and return the elements as well as ranks in pairs:
my @res = sortrankby "apple", "cucumber", "banana", "banana"; # => "banana","1=", "banana","1=", "apricot",3, "cucumber",4
Please visit the project's homepage at https://metacpan.org/release/List-Rank.
Source repository is at https://github.com/perlancar/perl-List-Rank.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=List-Rank
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Sort::Rank
perlancar <perlancar@cpan.org>
This software is copyright (c) 2018 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install List::Rank, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::Rank
CPAN shell
perl -MCPAN -e shell install List::Rank
For more information on module installation, please visit the detailed CPAN module installation guide.