Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.334.000 Times

Sort::Fields 0.90

  Date Added: October 22, 2010  |  Visits: 1.092

Sort::Fields

Report Broken Link
Printer Friendly Version


Product Homepage
Download (100 downloads)



Sort::Fields is a Perl module that can sort lines containing delimited fields. SYNOPSIS use Sort::Fields; @sorted = fieldsort [3, 2n], @lines; @sorted = fieldsort +, [-1, -3, 0], @lines; $sort_3_2n = make_fieldsort [3, 2n], @lines; @sorted = $sort_3_2n->(@lines); Sort::Fields provides a general purpose technique for efficiently sorting lists of lines that contain data separated into fields. Sort::Fields automatically imports two subroutines, fieldsort and make_fieldsort, and two variants, stable_fieldsort and make_stable_fieldsort. make_fieldsort generates a sorting subroutine and returns a reference to it. fieldsort is a wrapper for the make_fieldsort subroutine. The first argument to make_fieldsort is a delimiter string, which is used as a regular expression argument for a split operator. The delimiter string is optional. If it is not supplied, make_fieldsort splits each line using /s+/. The second argument is an array reference containing one or more field specifiers. The specifiers indicate what fields in the strings will be used to sort the data. The specifier "1" indicates the first field, "2" indicates the second, and so on. A negative specifier like "-2" means to sort on the second field in reverse (descending) order. To indicate a numeric rather than alphabetic comparison, append "n" to the specifier. A specifier of "0" means the entire string ("-0" means the entire string, in reverse order). The order in which the specifiers appear is the order in which they will be used to sort the data. The primary key is first, the secondary key is second, and so on. fieldsort [1, 2], @data is roughly equivalent to make_fieldsort([1, 2])->(@data). Avoid calling fieldsort repeatedly with the same sort specifiers. If you need to use a particular sort more than once, it is more efficient to call make_fieldsort once and reuse the subroutine it returns. stable_fieldsort and make_stable_fieldsort are like their "unstable" counterparts, except that the items that compare the same are maintained in their original order. EXAMPLES Some sample data (in array @data): 123 asd 1.22 asdd 32 ewq 2.32 asdd 43 rewq 2.12 ewet 51 erwt 34.2 ewet 23 erww 4.21 ewet 91 fdgs 3.43 ewet 123 refs 3.22 asdd 123 refs 4.32 asdd # alpha sort on column 1 print fieldsort [1], @data; 123 asd 1.22 asdd 123 refs 3.22 asdd 123 refs 4.32 asdd 23 erww 4.21 ewet 32 ewq 2.32 asdd 43 rewq 2.12 ewet 51 erwt 34.2 ewet 91 fdgs 3.43 ewet # numeric sort on column 1 print fieldsort [1n], @data; 23 erww 4.21 ewet 32 ewq 2.32 asdd 43 rewq 2.12 ewet 51 erwt 34.2 ewet 91 fdgs 3.43 ewet 123 asd 1.22 asdd 123 refs 3.22 asdd 123 refs 4.32 asdd # reverse numeric sort on column 1 print fieldsort [-1n], @data; 123 asd 1.22 asdd 123 refs 3.22 asdd 123 refs 4.32 asdd 91 fdgs 3.43 ewet 51 erwt 34.2 ewet 43 rewq 2.12 ewet 32 ewq 2.32 asdd 23 erww 4.21 ewet # alpha sort on column 2, then alpha on entire line print fieldsort [2, 0], @data; 123 asd 1.22 asdd 51 erwt 34.2 ewet 23 erww 4.21 ewet 32 ewq 2.32 asdd 91 fdgs 3.43 ewet 123 refs 3.22 asdd 123 refs 4.32 asdd 43 rewq 2.12 ewet # alpha sort on column 4, then numeric on column 1, then reverse # numeric on column 3 print fieldsort [4, 1n, -3n], @data; 32 ewq 2.32 asdd 123 refs 4.32 asdd 123 refs 3.22 asdd 123 asd 1.22 asdd 23 erww 4.21 ewet 43 rewq 2.12 ewet 51 erwt 34.2 ewet 91 fdgs 3.43 ewet # now, splitting on either literal period or whitespace # sort numeric on column 4 (fractional part of decimals) then # numeric on column 3 (whole part of decimals) print fieldsort (?:.|s+), [4n, 3n], @data; 51 erwt 34.2 ewet 43 rewq 2.12 ewet 23 erww 4.21 ewet 123 asd 1.22 asdd 123 refs 3.22 asdd 32 ewq 2.32 asdd 123 refs 4.32 asdd 91 fdgs 3.43 ewet # alpha sort on column 4, then numeric on the entire line # NOTE: produces warnings under -w print fieldsort [4, 0n], @data; 32 ewq 2.32 asdd 123 asd 1.22 asdd 123 refs 3.22 asdd 123 refs 4.32 asdd 23 erww 4.21 ewet 43 rewq 2.12 ewet 51 erwt 34.2 ewet 91 fdgs 3.43 ewet # stable alpha sort on column 4 (maintains original relative order # among items that compare the same) print stable_fieldsort [4], @data; 123 asd 1.22 asdd 32 ewq 2.32 asdd 123 refs 3.22 asdd 123 refs 4.32 asdd 43 rewq 2.12 ewet 51 erwt 34.2 ewet 23 erww 4.21 ewet 91 fdgs 3.43 ewet.

Requirements: No special requirements
Platforms: Linux
Keyword: Column Data Libraries Perl Module Programming Refs Sort Sort Lines Sortfields
Users rating: 0/10

License: Freeware Size: 5.12 KB
USER REVIEWS
More Reviews or Write Review


SORT::FIELDS RELATED
Libraries  -  Alien Perl module 0.91
Alien Perl module package contains external libraries wrapped up for your viewing pleasure! SYNOPSIS perldoc Alien; Alien is a package that exists just to hold together an idea, the idea of Alien:: packages, so there is no code here, just...
10.24 KB  
Libraries  -  Data::Region 1.0
Data::Region Perl module can define hierarchical areas with behaviors. SYNOPSIS use Data::Region; $r = Data::Region->new( 8.5, 11, { data => PageObj->new() } ); $r->data( PageObj->new() ); foreach my $c ( $r->subdivide(2.5,3) ) { $a =...
8.19 KB  
Libraries  -  Gtk2::Ex::MindMapView::Layout::Column 0.000001
Gtk2::Ex::MindMapView::Layout::Column is a Perl module to display vertical layout of clusters. SYNOPSIS use Gtk2::Ex::MindMapView::Layout::Column; The Gtk2::Ex::MindMapView::Layout::Column is used to layout Gtk2::Ex::MindMapView::Items in...
50.18 KB  
Libraries  -  OpenGeoDB Perl module 0.4
OpenGeDB Perl module is a module to access the OpenGeoDB database and calculate all ZIP codes in a certain radius..
3.07 KB  
Network & Internet  -  MyCMS perl module 1.0
MyCMS perl module provides the MN::CMS Perl module used by the MyCMS. MyCMS perl module contains Perl object classes to manage the data of MyCMS (such as articles, links, and images). MN::CMS is a perl module that allows you to manage an...
16.38 KB  
Libraries  -  Sort::Half::Maker 0.03
Sort::Half::Maker is a Perl module to create half-sort subs easily. SYNOPSIS use Sort::Half::Maker qw(make_halfsort); $sub = make_halfsort( start => [ qw(x y z) ], end => [ qw(a b c) ], fallback => sub { $_[0] cmp $_[1] }, ); @list =...
4.1 KB  
Libraries  -  Sort::ArbBiLex 4.01
Sort::ArbBiLex is a Perl module that can make sort functions for arbitrary sort orders. SYNOPSIS use Sort::ArbBiLex ( fulani_sort, # ask for a &fulani_sort to be defined "a A c C ch Ch CH ch Ch CH e E l L lh Lh LH n N r R s S u U...
16.38 KB  
Libraries  -  Config::Framework 2.5
Config::Framework is a Perl module with handy one-stop shopping for (most) of your configuration file needs. SYNOPSIS #create a new object, load two configuration files and decrypt the passwords. my $Object = new Config::Framework( Files =>...
15.36 KB  
Libraries  -  Class::Meta::Type 0.53
Class::Meta::Type is a Perl module for data type validation and accessor building. SYNOPSIS package MyApp::TypeDef; use strict; use Class::Meta::Type; use IO::Socket; my $type = Class::Meta::Type->add( key => io_socket, desc =>...
61.44 KB  
Libraries  -  Ace::Object 1.89
Ace::Object is a Perl module to manipulate Ace Data Objects. SYNOPSIS # open database connection and get an object use Ace; $db = Ace->connect(-host => beta.crbm.cnrs-mop.fr, -port => 20000100); $sequence = $db->fetch(Sequence => D12345);...
296.96 KB  
NEW DOWNLOADS IN PROGRAMMING, LIBRARIES
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB  
Libraries  -  wolfSSL 4.0.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB