perl-Sort-BySpec-0.03-alt1.noarch.rpm


Advertisement

Description

perl-Sort-BySpec - Sort array (or create a list sorter) according to specification

Property Value
Distribution ALT Linux Sisyphus
Repository Autoimports noarch
Package name perl-Sort-BySpec
Package version 0.03
Package release alt1
Package architecture noarch
Package type rpm
Installed size 32.93 KB
Download size 32.93 KB
Official Mirror ftp.altlinux.org
This package provides a more powerful alternative to the Sort::ByExample manpage. Unlike
in `Sort::ByExample` where you only provide a single array of example, you can
specify multiple examples as well as regex or matcher subroutine coupled with
sort rules. With this, you can more precisely specify how elements of your list
should be ordered. If your needs are not met by Sort::ByExample, you might want
to consider this package. The downside is performance penalty, especially when
your list is large.
To sort using Sort::BySpec, you provide a "spec" which is an array of strings,
regexes, or coderefs to match against elements of your list to be sorted. In the
simplest form, the spec contains only a list of examples:
my $sorter = sort_by_spec(spec => ["foo", "bar", "baz"]); # [1]
and this is equivalent to Sort::ByExample:
my $sorter = sbe(["foo", "bar", "baz"]);
You can also specify regex to match elements. This is evaluated after strings,
so this work:
my $sorter = sort_by_spec(spec => [qr/o/, "foo", "bar", "baz", qr/a/]);
my @list = ("foo", "food", "bar", "back", "baz", "fool", "boat");
my @res = $sorter->(@list);
Right after a regex, you can optionally specify a sort subroutine to tell how to
sort elements matching that regex, for example:
my $sorter = sort_by_spec(spec => [
qr/o/ => sub { $_[0] cmp $_[1] },
"foo", "bar", "baz",
qr/a/
]);
Note that instead of `$a' and `$b', you should use `$_[0]' and `$_[1]'
respectively. This avoids the package scoping issue of `$a' and `$b', making
your sorter subroutine works everywhere without any special workaround.
Finally, aside from strings and regexes, you can also specify a coderef matcher
for more complex matching:
my $sorter = sort_by_spec(spec => [
sub { $_[0] % 2 } => sub { $_[0] <=> $_[1] },

Alternatives

Package Version Architecture Repository
perl-Sort-BySpec - - -

Requires

Name Value
/usr/share/perl5 -
perl-base >= 1:5.10.1
rpmlib(PayloadIsLzma) -

Provides

Name Value
perl(Sort/BySpec.pm) = 0.030
perl-Sort-BySpec = 0.03-alt1

Download

Type URL
Binary Package perl-Sort-BySpec-0.03-alt1.noarch.rpm
Source Package perl-Sort-BySpec-0.03-alt1.src.rpm

Install Howto

  1. Add the following line to /etc/apt/sources.list:
    
    rpm [Sisyphus] http://ftp.altlinux.org/pub/distributions/ALTLinux/autoimports/Sisyphus noarch autoimports
    rpm [Sisyphus] http://ftp.altlinux.org/pub/distributions/ALTLinux/autoimports/Sisyphus noarch autoimports
    
  2. Update the package index:
    # sudo apt-get update
  3. Install perl-Sort-BySpec rpm package:
    # sudo apt-get install perl-Sort-BySpec

Files

Path
/usr/share/doc/perl-Sort-BySpec-0.03/Changes
/usr/share/doc/perl-Sort-BySpec-0.03/LICENSE
/usr/share/doc/perl-Sort-BySpec-0.03/README
/usr/share/perl5/Sort/BySpec.pm

See Also

Package Description
perl-Sort-DataTypes-3.01-alt1.noarch.rpm Sort a list of data using methods relevant to the type of data
perl-Sort-Fields-0.90-alt1.noarch.rpm perl module Sort-Fields
perl-Sort-Half-Maker-0.04-alt1.noarch.rpm Create half-sort subs easily
perl-Sort-Hash-2.05-alt1.noarch.rpm Suite 330, Boston, MA 02111-1307, USA
perl-Sort-Hash-Values-0.1.1-alt1.noarch.rpm sort hashes by values
perl-Sort-Key-DateTime-0.07-alt1.noarch.rpm Perl extension for sorting objects by some DateTime key
perl-Sort-Key-Top-PP-0.003-alt1.noarch.rpm pure Perl implementation of parts of Sort::Key::Top
perl-Sort-Maker-0.06-alt1.noarch.rpm perl module Sort-Maker
perl-Sort-Merge-0.01-alt1.noarch.rpm perl module Sort-Merge
perl-Sort-MergeSort-0.31-alt1.noarch.rpm perl module Sort-MergeSort
perl-Sort-MultipleFields-1.01-alt2.noarch.rpm Conveniently sort on multiple fields
perl-Sort-Radix-0.04-alt1.noarch.rpm perl module Sort-Radix
perl-Sort-Rank-0.0.2-alt1.noarch.rpm Sort arrays by some score and organise into ranks
perl-Sort-SQL-0.08-alt1.noarch.rpm manipulate SQL sort strings
perl-Sort-Sub-0.110-alt1.noarch.rpm Collection of sort subroutines
Advertisement
Advertisement