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


Advertisement

Description

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

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

Requires

Provides

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

    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

    • /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
    Advertisement
    Advertisement