sorted
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 967
Tie::Hash::Sorted 0.10
Tie::Hash::Sorted Perl module presents hashes in sorted order. more>>
Tie::Hash::Sorted Perl module presents hashes in sorted order.
SYNOPSIS
use Tie::Hash::Sorted;
my %ages = (
John => 33,
Jacob => 29,
Jingle => 15,
Heimer => 48,
Smitz => 12,
);
my $sort_by_numeric_value = sub {
my $hash = shift;
[ sort {$hash->{$b} $hash->{$a}} keys %$hash ];
};
tie my %sorted_ages, Tie::Hash::Sorted,
Hash => %ages,
Sort_Routine => $sort_by_numeric_value;
for my $name ( keys %sorted_ages ) {
print "$name is $sorted_ages{$name} years old.n";
}
### OUTPUT ###
Heimer is 48 ears old.
John is 33 ears old.
Jacob is 29 ears old.
Jingle is 15 ears old.
Smitz is 12 ears old.
<<lessSYNOPSIS
use Tie::Hash::Sorted;
my %ages = (
John => 33,
Jacob => 29,
Jingle => 15,
Heimer => 48,
Smitz => 12,
);
my $sort_by_numeric_value = sub {
my $hash = shift;
[ sort {$hash->{$b} $hash->{$a}} keys %$hash ];
};
tie my %sorted_ages, Tie::Hash::Sorted,
Hash => %ages,
Sort_Routine => $sort_by_numeric_value;
for my $name ( keys %sorted_ages ) {
print "$name is $sorted_ages{$name} years old.n";
}
### OUTPUT ###
Heimer is 48 ears old.
John is 33 ears old.
Jacob is 29 ears old.
Jingle is 15 ears old.
Smitz is 12 ears old.
Download (0.008MB)
Added: 2007-07-13 License: Perl Artistic License Price:
833 downloads
Apache::MP3::Sorted 4.00
Apache::MP3::Sorted is a Perl module to generate sorted streamable directories of MP3 files. more>>
Apache::MP3::Sorted is a Perl module to generate sorted streamable directories of MP3 files.
SYNOPSIS
# httpd.conf or srm.conf
AddType audio/mpeg mp3 MP3
# httpd.conf or access.conf
< Location /songs >
SetHandler perl-script
PerlHandler Apache::MP3::Sorted
PerlSetVar SortFields Album,Title,-Duration
PerlSetVar Fields Title,Artist,Album,Duration
< /Location >
Apache::MP3::Sorted subclasses Apache::MP3 to allow for sorting of MP3 listings by various criteria. See Apache::MP3 for details on installing and using.
<<lessSYNOPSIS
# httpd.conf or srm.conf
AddType audio/mpeg mp3 MP3
# httpd.conf or access.conf
< Location /songs >
SetHandler perl-script
PerlHandler Apache::MP3::Sorted
PerlSetVar SortFields Album,Title,-Duration
PerlSetVar Fields Title,Artist,Album,Duration
< /Location >
Apache::MP3::Sorted subclasses Apache::MP3 to allow for sorting of MP3 listings by various criteria. See Apache::MP3 for details on installing and using.
Download (0.32MB)
Added: 2006-11-07 License: Perl Artistic License Price:
1082 downloads
Sort::Fields 0.90
Sort::Fields is a Perl module that can sort lines containing delimited fields. more>>
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
<<lessSYNOPSIS
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
Download (0.005MB)
Added: 2007-05-21 License: Perl Artistic License Price:
887 downloads
Sort::Key 1.28
Sort::Key is the fastest way to sort anything in Perl. more>>
Sort::Key is the fastest way to sort anything in Perl.
SYNOPSIS
use Sort::Key qw(keysort nkeysort ikeysort);
@by_name = keysort { "$_->{surname} $_->{name}" } @people;
# sorting by a numeric key:
@by_age = nkeysort { $_->{age} } @people;
# sorting by a numeric integer key:
@by_sons = ikeysort { $_->{sons} } @people;
Sort::Key provides a set of functions to sort lists of values by some calculated key value.
It is faster (usually much faster) and uses less memory than other alternatives implemented around perl sort function (ST, GRT, etc.).
Multikey sorting functionality is also provided via the companion modules Sort::Key::Multi, Sort::Key::Maker and Sort::Key::Register.
FUNCTIONS
This module provides a large number of sorting subroutines but they are all variations off the keysort one:
@sorted = keysort { CALC_KEY($_) } @data
that is conceptually equivalent to
@sorted = sort { CALC_KEY($a) cmp CALC_KEY($b) } @data
and where CALC_KEY($_) can be any expresion to extract the key value from $_ (not only a subroutine call).
For instance, some variations are nkeysort that performs a numeric comparison, rkeysort that orders the data in descending order, ikeysort and ukeysort that are optimized versions of nkeysort that can be used when the keys are integers or unsigned integers respectively, etc.
Also, inplace versions of the sorters are provided. For instance
keysort_inplace { CALC_KEY($_) } @data
that is equivalent to
@data = keysort { CALC_KEY($_) } @data
but being (a bit) faster and using less memory.
The full list of subroutines that can be imported from this module follows:
keysort { CALC_KEY } @array
returns the elements on @array sorted by the key calculated applying { CALC_KEY } to them.
Inside { CALC_KEY }, the object is available as $_.
For example:
@a=({name=>john, surname=>smith}, {name=>paul, surname=>belvedere});
@by_name=keysort {$_->{name}} @a;
This function honours the use locale pragma.
nkeysort { CALC_KEY } @array
similar to keysort but compares the keys numerically instead of as strings.
This function honours the use integer pragma, i.e.:
use integer;
my @s=(2.4, 2.0, 1.6, 1.2, 0.8);
my @ns = nkeysort { $_ } @s;
print "@nsn"
prints
0.8 1.6 1.2 2.4 2
rnkeysort { CALC_KEY } @array
works as nkeysort, comparing keys in reverse (or descending) numerical order.
ikeysort { CALC_KEY } @array
works as keysort but compares the keys as integers (32 bits or more, no checking is performed for overflows).
rikeysort { CALC_KEY } @array
works as ikeysort, but in reverse (or descending) order.
ukeysort { CALC_KEY } @array
works as keysort but compares the keys as unsigned integers (32 bits or more).
For instance, it can be used to efficiently sort IP4 addresses:
my @data = qw(1.2.3.4 4.3.2.1 11.1.111.1 222.12.1.34
0.0.0.0 255.255.255.0) 127.0.0.1);
my @sorted = ukeysort {
my @a = split /./;
(((($a[0] name,
$_->middlename },
qw(str str str);
Sort::Key::register_type Color =>
sub { $_->R, $_->G, $_->B },
qw(int int int);
Once a datatype has been registered it can be used in the same way as types supported natively, even for defining new types, i.e.:
Sort::Key::register_type Family =>
sub { $_->man, $_->woman },
qw(Person Person);
<<lessSYNOPSIS
use Sort::Key qw(keysort nkeysort ikeysort);
@by_name = keysort { "$_->{surname} $_->{name}" } @people;
# sorting by a numeric key:
@by_age = nkeysort { $_->{age} } @people;
# sorting by a numeric integer key:
@by_sons = ikeysort { $_->{sons} } @people;
Sort::Key provides a set of functions to sort lists of values by some calculated key value.
It is faster (usually much faster) and uses less memory than other alternatives implemented around perl sort function (ST, GRT, etc.).
Multikey sorting functionality is also provided via the companion modules Sort::Key::Multi, Sort::Key::Maker and Sort::Key::Register.
FUNCTIONS
This module provides a large number of sorting subroutines but they are all variations off the keysort one:
@sorted = keysort { CALC_KEY($_) } @data
that is conceptually equivalent to
@sorted = sort { CALC_KEY($a) cmp CALC_KEY($b) } @data
and where CALC_KEY($_) can be any expresion to extract the key value from $_ (not only a subroutine call).
For instance, some variations are nkeysort that performs a numeric comparison, rkeysort that orders the data in descending order, ikeysort and ukeysort that are optimized versions of nkeysort that can be used when the keys are integers or unsigned integers respectively, etc.
Also, inplace versions of the sorters are provided. For instance
keysort_inplace { CALC_KEY($_) } @data
that is equivalent to
@data = keysort { CALC_KEY($_) } @data
but being (a bit) faster and using less memory.
The full list of subroutines that can be imported from this module follows:
keysort { CALC_KEY } @array
returns the elements on @array sorted by the key calculated applying { CALC_KEY } to them.
Inside { CALC_KEY }, the object is available as $_.
For example:
@a=({name=>john, surname=>smith}, {name=>paul, surname=>belvedere});
@by_name=keysort {$_->{name}} @a;
This function honours the use locale pragma.
nkeysort { CALC_KEY } @array
similar to keysort but compares the keys numerically instead of as strings.
This function honours the use integer pragma, i.e.:
use integer;
my @s=(2.4, 2.0, 1.6, 1.2, 0.8);
my @ns = nkeysort { $_ } @s;
print "@nsn"
prints
0.8 1.6 1.2 2.4 2
rnkeysort { CALC_KEY } @array
works as nkeysort, comparing keys in reverse (or descending) numerical order.
ikeysort { CALC_KEY } @array
works as keysort but compares the keys as integers (32 bits or more, no checking is performed for overflows).
rikeysort { CALC_KEY } @array
works as ikeysort, but in reverse (or descending) order.
ukeysort { CALC_KEY } @array
works as keysort but compares the keys as unsigned integers (32 bits or more).
For instance, it can be used to efficiently sort IP4 addresses:
my @data = qw(1.2.3.4 4.3.2.1 11.1.111.1 222.12.1.34
0.0.0.0 255.255.255.0) 127.0.0.1);
my @sorted = ukeysort {
my @a = split /./;
(((($a[0] name,
$_->middlename },
qw(str str str);
Sort::Key::register_type Color =>
sub { $_->R, $_->G, $_->B },
qw(int int int);
Once a datatype has been registered it can be used in the same way as types supported natively, even for defining new types, i.e.:
Sort::Key::register_type Family =>
sub { $_->man, $_->woman },
qw(Person Person);
Download (0.055MB)
Added: 2007-05-22 License: Perl Artistic License Price:
888 downloads
Sort::Radix 0.04
Sort::Radix is a Perl module with multiple passes distribution sort algorithm. more>>
Sort::Radix is a Perl module with multiple passes distribution sort algorithm.
SYNOPSIS
use Sort::Radix;
@array = qw(flow loop pool Wolf root sort tour);
radix_sort(@array);
print "@arrayn";
This is an implementation based on Jarkkos Wolf book (Mastering Algorithms with Perl, pp. 145-147).
By definition: radix sort is a multiple pass distribution sort algorithm that distributes each item to a bucket according to part of the items key beginning with the least significant part of the key. After each pass, items are collected from the buckets, keeping the items in order, then redistribute according to the next most significant part of the key.
Radix sort is nice as it take N * M passes, where N is the length of the keys. It is very useful for sorting large volumes of keys of the same length, such as postal codes.
The algorithm will only works when the strings to be sorted are of the same length. Variable length strings therefore have to be padded with zeroes (x00) to equalize the length.
<<lessSYNOPSIS
use Sort::Radix;
@array = qw(flow loop pool Wolf root sort tour);
radix_sort(@array);
print "@arrayn";
This is an implementation based on Jarkkos Wolf book (Mastering Algorithms with Perl, pp. 145-147).
By definition: radix sort is a multiple pass distribution sort algorithm that distributes each item to a bucket according to part of the items key beginning with the least significant part of the key. After each pass, items are collected from the buckets, keeping the items in order, then redistribute according to the next most significant part of the key.
Radix sort is nice as it take N * M passes, where N is the length of the keys. It is very useful for sorting large volumes of keys of the same length, such as postal codes.
The algorithm will only works when the strings to be sorted are of the same length. Variable length strings therefore have to be padded with zeroes (x00) to equalize the length.
Download (0.003MB)
Added: 2007-05-22 License: Perl Artistic License Price:
885 downloads
phpSortable 2.0
phpSortable is a PHP class that shows MySQL QueryResults in an HTML table. more>>
phpSortable project is a PHP class that shows MySQL QueryResults in an HTML table. As implied by the name "Sortable", the table also displays the column headers as links which lead to a version of the table that is sorted according to that column.
Furthermore, it allows you to link the individual rows with other scripts for modifying the rows. The class also permits the user to limit the number of rows to display at once. The table can also be navigated with the "last" and "next" links.
Enhancements:
- The class is now named phpSortable instead of phpSortTable.
- It has a database abstraction interface, so it is possible to work not only with MySQL but with any other database types.
- Therefore, the activeDBLib class must be used, and it can be found at PHPClasses.org.
<<lessFurthermore, it allows you to link the individual rows with other scripts for modifying the rows. The class also permits the user to limit the number of rows to display at once. The table can also be navigated with the "last" and "next" links.
Enhancements:
- The class is now named phpSortable instead of phpSortTable.
- It has a database abstraction interface, so it is possible to work not only with MySQL but with any other database types.
- Therefore, the activeDBLib class must be used, and it can be found at PHPClasses.org.
Download (0.15MB)
Added: 2007-02-16 License: GPL (GNU General Public License) Price:
588 downloads
Sort MP3 0.1
Sort MP3 is a script was made to help in organizing MP3s. more>>
Sort MP3 is a script was made to help in organizing MP3s. If you have one directory with allot of mp3s and the names are not very readable you can run this script against them. It will read the id tag of a mp3 and rename the file to the title of the song but with _ instead of spaces. It can also create a directory structure from the id tag if the -c option is used. The structure will be put in the same directory the mp3s are in. It will be something like: "/BANDNAME/CDTITLE/SONG.mp3"
Usage: sort_mp3.pl [options]
Options should be separated by a space and my be
in any order.
-c Create a directory structure from the mp3 tag.
It is made inside the directory holding the un-named mp3s.
If not set the files will just be renamed.
Example: "/BANDNAME/CDTITLE/SONG.mp3"
-d= Path to the directory where mp3s can be found.
There should be no / at the end and no spaces.
Example: "-d=/unsorted_mp3s"
<<lessUsage: sort_mp3.pl [options]
Options should be separated by a space and my be
in any order.
-c Create a directory structure from the mp3 tag.
It is made inside the directory holding the un-named mp3s.
If not set the files will just be renamed.
Example: "/BANDNAME/CDTITLE/SONG.mp3"
-d= Path to the directory where mp3s can be found.
There should be no / at the end and no spaces.
Example: "-d=/unsorted_mp3s"
Download (0.002MB)
Added: 2006-07-24 License: GPL (GNU General Public License) Price:
1196 downloads
Sort::Versions 1.5
Sort::Versions is a Perl 5 module for sorting of revision-like numbers. more>>
Sort::Versions is a Perl 5 module for sorting of revision-like numbers.
SYNOPSIS
use Sort::Versions;
@l = sort { versioncmp($a, $b) } qw( 1.2 1.2.0 1.2a.0 1.2.a 1.a 02.a );
...
use Sort::Versions;
print lower if versioncmp(1.2, 1.2a) == -1;
...
use Sort::Versions;
%h = (1 => d, 2 => c, 3 => b, 4 => a);
@h = sort { versioncmp($h{$a}, $h{$b}) } keys %h;
Sort::Versions allows easy sorting of mixed non-numeric and numeric strings, like the version numbers that many shared library systems and revision control packages use. This is quite useful if you are trying to deal with shared libraries. It can also be applied to applications that intersperse variable-width numeric fields within text. Other applications can undoubtedly be found.
For an explanation of the algorithm, its simplest to look at these examples:
1.1 < 1.2
1.1a < 1.2
1.1 < 1.1.1
1.1 < 1.1a
1.1.a < 1.1a
1 < a
a < b
1 < 2
1.1-3 < 1.1-4
1.1-5 < 1.1.6
More precisely (but less comprehensibly), the two strings are treated as subunits delimited by periods or hyphens. Each subunit can contain any number of groups of digits or non-digits. If digit groups are being compared on both sides, a numeric comparison is used, otherwise a ASCII ordering is used. A group or subgroup with more units will win if all comparisons are equal. A period binds digit groups together more tightly than a hyphen.
Some packages use a different style of version numbering: a simple real number written as a decimal. Sort::Versions has limited support for this style: when comparing two subunits which are both digit groups, if either subunit has a leading zero, then both are treated like digits after a decimal point. So for example:
0002 < 1
1.06 < 1.5
This wont always work, because there wont always be a leading zero in real-number style version numbers. There is no way for Sort::Versions to know which style was intended. But a lot of the time it will do the right thing. If you are making up version numbers, the style with (possibly) more than one dot is the style to use.
USAGE
The function versioncmp() takes two arguments and compares them like cmp. With perl 5.6 or later, you can also use this function directly in sorting:
@l = sort versioncmp qw(1.1 1.2 1.0.3);
The function versions() can be used directly as a sort function even on perl 5.005 and earlier, but its use is deprecated.
<<lessSYNOPSIS
use Sort::Versions;
@l = sort { versioncmp($a, $b) } qw( 1.2 1.2.0 1.2a.0 1.2.a 1.a 02.a );
...
use Sort::Versions;
print lower if versioncmp(1.2, 1.2a) == -1;
...
use Sort::Versions;
%h = (1 => d, 2 => c, 3 => b, 4 => a);
@h = sort { versioncmp($h{$a}, $h{$b}) } keys %h;
Sort::Versions allows easy sorting of mixed non-numeric and numeric strings, like the version numbers that many shared library systems and revision control packages use. This is quite useful if you are trying to deal with shared libraries. It can also be applied to applications that intersperse variable-width numeric fields within text. Other applications can undoubtedly be found.
For an explanation of the algorithm, its simplest to look at these examples:
1.1 < 1.2
1.1a < 1.2
1.1 < 1.1.1
1.1 < 1.1a
1.1.a < 1.1a
1 < a
a < b
1 < 2
1.1-3 < 1.1-4
1.1-5 < 1.1.6
More precisely (but less comprehensibly), the two strings are treated as subunits delimited by periods or hyphens. Each subunit can contain any number of groups of digits or non-digits. If digit groups are being compared on both sides, a numeric comparison is used, otherwise a ASCII ordering is used. A group or subgroup with more units will win if all comparisons are equal. A period binds digit groups together more tightly than a hyphen.
Some packages use a different style of version numbering: a simple real number written as a decimal. Sort::Versions has limited support for this style: when comparing two subunits which are both digit groups, if either subunit has a leading zero, then both are treated like digits after a decimal point. So for example:
0002 < 1
1.06 < 1.5
This wont always work, because there wont always be a leading zero in real-number style version numbers. There is no way for Sort::Versions to know which style was intended. But a lot of the time it will do the right thing. If you are making up version numbers, the style with (possibly) more than one dot is the style to use.
USAGE
The function versioncmp() takes two arguments and compares them like cmp. With perl 5.6 or later, you can also use this function directly in sorting:
@l = sort versioncmp qw(1.1 1.2 1.0.3);
The function versions() can be used directly as a sort function even on perl 5.005 and earlier, but its use is deprecated.
Download (0.005MB)
Added: 2007-05-22 License: Perl Artistic License Price:
885 downloads
Sort::External 0.16
Sort::External is a Perl module that can sort huge lists. more>>
Sort::External is a Perl module that can sort huge lists.
SYNOPSIS
my $sortex = Sort::External->new( -mem_threshold => 2**24 );
while ( ) {
$sortex->feed($_);
}
$sortex->finish;
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Problem: You have a list which is too big to sort in-memory.
Solution: "feed, finish, and fetch" with Sort::External, the closest thing to a drop-in replacement for Perls sort() function when dealing with unmanageably large lists.
How it works:
Cache sortable items in memory. Periodically sort the cache and empty it into a temporary sortfile. As sortfiles accumulate, interleave them into larger sortfiles. Complete the sort by sorting the input cache and any existing sortfiles into an output stream.
Note that if Sort::External hasnt yet flushed the cache to disk when finish() is called, the whole operation completes in-memory.
In the CompSci world, "internal sorting" refers to sorting data in RAM, while "external sorting" refers to sorting data which is stored on disk, tape, punchcards, or any storage medium except RAM -- hence, this modules name.
Stringification
Items fed to Sort::External will be returned in stringified form (assuming that the cache gets flushed at least once): $foo = "$foo". Since this is unlikely to be desirable when objects or deep data structures are involved, Sort::External throws an error if you feed it anything other than simple scalars.
Taint and UTF-8 flags
Expert: Sort::External does a little extra bookkeeping to sustain each items taint and UTF-8 flags through the journey to disk and back.
METHODS
new()
my $sortscheme = sub { $Sort::External::b $Sort::External::a };
my $sortex = Sort::External->new(
-mem_threshold => 2**24, # default: 2**20 (1Mb)
-cache_size => 100_000, # default: undef (disabled)
-sortsub => $sortscheme, # default sort: standard lexical
-working_dir => $temp_directory, # default: see below
);
Construct a Sort::External object.
-mem_threshold -- Allow the input cache to consume approximately -mem_threshold bytes before sorting it and flushing to disk. Experience suggests that the optimum setting is somewhere between 2**20 and 2**24: 1-16Mb.
-cache_size -- Specify a hard limit for the input cache in terms of sortable items. If set, overrides -mem_threshold.
-sortsub -- A sorting subroutine. Be advised that you MUST use $Sort::External::a and $Sort::External::b instead of $a and $b in your sub. Before deploying a sortsub, consider using a GRT instead, as described in the Sort::External::Cookbook. Its probably a lot faster.
-working_dir -- The directory where the temporary sortfiles will reside. By default, this directory is created using File::Temps tempdir() command.
feed()
$sortex->feed( @items );
Feed one or more sortable items to your Sort::External object. It is normal for occasional pauses to occur during feeding as caches are flushed and sortfiles are merged.
finish()
# if you intend to call fetch...
$sortex->finish;
# otherwise....
use Fcntl;
$sortex->finish(
-outfile => sorted.txt,
-flags => (O_CREAT | O_WRONLY),
);
Prepare to output items in sorted order.
If you specify the parameter -outfile, Sort::External will attempt to write your sorted list to that location. By default, Sort::External will refuse to overwrite an existing file; if you want to override that behavior, you can pass Fcntl flags to finish() using the optional -flags parameter.
Note that you can either finish() to an -outfile, or finish() then fetch()... but not both.
fetch()
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Fetch the next sorted item.
<<lessSYNOPSIS
my $sortex = Sort::External->new( -mem_threshold => 2**24 );
while ( ) {
$sortex->feed($_);
}
$sortex->finish;
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Problem: You have a list which is too big to sort in-memory.
Solution: "feed, finish, and fetch" with Sort::External, the closest thing to a drop-in replacement for Perls sort() function when dealing with unmanageably large lists.
How it works:
Cache sortable items in memory. Periodically sort the cache and empty it into a temporary sortfile. As sortfiles accumulate, interleave them into larger sortfiles. Complete the sort by sorting the input cache and any existing sortfiles into an output stream.
Note that if Sort::External hasnt yet flushed the cache to disk when finish() is called, the whole operation completes in-memory.
In the CompSci world, "internal sorting" refers to sorting data in RAM, while "external sorting" refers to sorting data which is stored on disk, tape, punchcards, or any storage medium except RAM -- hence, this modules name.
Stringification
Items fed to Sort::External will be returned in stringified form (assuming that the cache gets flushed at least once): $foo = "$foo". Since this is unlikely to be desirable when objects or deep data structures are involved, Sort::External throws an error if you feed it anything other than simple scalars.
Taint and UTF-8 flags
Expert: Sort::External does a little extra bookkeeping to sustain each items taint and UTF-8 flags through the journey to disk and back.
METHODS
new()
my $sortscheme = sub { $Sort::External::b $Sort::External::a };
my $sortex = Sort::External->new(
-mem_threshold => 2**24, # default: 2**20 (1Mb)
-cache_size => 100_000, # default: undef (disabled)
-sortsub => $sortscheme, # default sort: standard lexical
-working_dir => $temp_directory, # default: see below
);
Construct a Sort::External object.
-mem_threshold -- Allow the input cache to consume approximately -mem_threshold bytes before sorting it and flushing to disk. Experience suggests that the optimum setting is somewhere between 2**20 and 2**24: 1-16Mb.
-cache_size -- Specify a hard limit for the input cache in terms of sortable items. If set, overrides -mem_threshold.
-sortsub -- A sorting subroutine. Be advised that you MUST use $Sort::External::a and $Sort::External::b instead of $a and $b in your sub. Before deploying a sortsub, consider using a GRT instead, as described in the Sort::External::Cookbook. Its probably a lot faster.
-working_dir -- The directory where the temporary sortfiles will reside. By default, this directory is created using File::Temps tempdir() command.
feed()
$sortex->feed( @items );
Feed one or more sortable items to your Sort::External object. It is normal for occasional pauses to occur during feeding as caches are flushed and sortfiles are merged.
finish()
# if you intend to call fetch...
$sortex->finish;
# otherwise....
use Fcntl;
$sortex->finish(
-outfile => sorted.txt,
-flags => (O_CREAT | O_WRONLY),
);
Prepare to output items in sorted order.
If you specify the parameter -outfile, Sort::External will attempt to write your sorted list to that location. By default, Sort::External will refuse to overwrite an existing file; if you want to override that behavior, you can pass Fcntl flags to finish() using the optional -flags parameter.
Note that you can either finish() to an -outfile, or finish() then fetch()... but not both.
fetch()
while ( defined( $_ = $sortex->fetch ) ) {
&do_stuff_with($_);
}
Fetch the next sorted item.
Download (0.022MB)
Added: 2007-05-21 License: Perl Artistic License Price:
886 downloads
Sort::ArbBiLex 4.01
Sort::ArbBiLex is a Perl module that can make sort functions for arbitrary sort orders. more>> <<less
Download (0.016MB)
Added: 2007-07-12 License: Perl Artistic License Price:
835 downloads
Genre-sort 1.0
Genre-sort is a script that parses ID3 tags for all MP3 files in a directory. more>>
Genre-sort is a handy Python script that will move/copy mp3s based on their id3 genre tag.
Main features:
- Written in Python
- Uses the eyeD3 library http://eyed3.nicfit.net/
- Currently only works on mp3 but ogg vorbis and flac support is planned
Examples:
./genre-sort.py /dir/to/files -p
Will run in pretend mode and show you what the script plans to do.
./genre-sort.py /dir/to/files -c
Will make copies of the files in the correct directories and leave the originals behind.
./genre-sort.py /dir/to/files
Default behavior will move files to the correct directories and delete the originals.
<<lessMain features:
- Written in Python
- Uses the eyeD3 library http://eyed3.nicfit.net/
- Currently only works on mp3 but ogg vorbis and flac support is planned
Examples:
./genre-sort.py /dir/to/files -p
Will run in pretend mode and show you what the script plans to do.
./genre-sort.py /dir/to/files -c
Will make copies of the files in the correct directories and leave the originals behind.
./genre-sort.py /dir/to/files
Default behavior will move files to the correct directories and delete the originals.
Download (0.002MB)
Added: 2005-09-15 License: GPL (GNU General Public License) Price:
1502 downloads
Sort::Key::Top 0.01
Sort::Key::Top is a Perl module that can select and sort top n elements. more>>
Sort::Key::Top is a Perl module that can select and sort top n elements.
SYNOPSIS
use Sort::Key::Top (nkeytop top);
# select 5 first numbers by absolute value:
@top = nkeytop { abs $_ } 5 => 1, 2, 7, 5, 5, 1, 78, 0, -2, -8, 2;
# ==> @top = (1, 2, 1, 0, -2)
# select 5 first words by lexicographic order:
@a = qw(cat fish bird leon penguin horse rat elephant squirrel dog);
@top = top 5 => @a;
# ==> @top = qw(cat fish bird elephant dog);
The functions available from this module select the top n elements from a list using several common orderings and custom key extraction procedures.
They are all variations around
keytopsort { CALC_KEY($_) } $n => @data;
This function calculates the ordering key for every element in @data using the expression inside the block. Then it selects and orders the $n elements with the lower keys when compared lexicographically.
It is equivalent to the pure Perl expression:
(sort { CALC_KEY($a) cmp CALC_KEY($b) } @data)[0 .. $n-1];
Variations allow to:
- use the own values as the ordering keys
topsort 5 => qw(a b ab t uu g h aa aac);
==> a aa aac ab b
- return the selected values in the original order
top 5 => qw(a b ab t uu g h aa aac);
==> a b ab aa aac
- use a different ordering
For instance comparing the keys as numbers, using the locale configuration or in reverse order:
rnkeytop { length $_ } 3 => qw(a ab aa aac b t uu g h);
==> ab aa aac
rnkeytopsort { length $_ } 3 => qw(a ab aa aac b t uu g h);
==> aac ab aa
A prefix is used to indicate the required ordering:
(no prefix)
lexicographical ascending order
r
lexicographical descending order
l
lexicographical ascending order obeying locale configuration
r
lexicographical descending order obeying locale configuration
n
numerical ascending order
rn
numerical descending order
i
numerical ascending order but converting the keys to integers first
ri
numerical descending order but converting the keys to integers first
u
numerical ascending order but converting the keys to unsigned integers first
ru
numerical descending order but converting the keys to unsigned integers first
The full list of available functions is:
top ltop ntop itop utop rtop rltop rntop ritop rutop
keytop lkeytop nkeytop ikeytop ukeytop rkeytop rlkeytop rnkeytop
rikeytop rukeytop
topsort ltopsort ntopsort itopsort utopsort rtopsort rltopsort
rntopsort ritopsort rutopsort
keytopsort lkeytopsort nkeytopsort ikeytopsort ukeytopsort
rkeytopsort rlkeytopsort rnkeytopsort rikeytopsort rukeytopsort
<<lessSYNOPSIS
use Sort::Key::Top (nkeytop top);
# select 5 first numbers by absolute value:
@top = nkeytop { abs $_ } 5 => 1, 2, 7, 5, 5, 1, 78, 0, -2, -8, 2;
# ==> @top = (1, 2, 1, 0, -2)
# select 5 first words by lexicographic order:
@a = qw(cat fish bird leon penguin horse rat elephant squirrel dog);
@top = top 5 => @a;
# ==> @top = qw(cat fish bird elephant dog);
The functions available from this module select the top n elements from a list using several common orderings and custom key extraction procedures.
They are all variations around
keytopsort { CALC_KEY($_) } $n => @data;
This function calculates the ordering key for every element in @data using the expression inside the block. Then it selects and orders the $n elements with the lower keys when compared lexicographically.
It is equivalent to the pure Perl expression:
(sort { CALC_KEY($a) cmp CALC_KEY($b) } @data)[0 .. $n-1];
Variations allow to:
- use the own values as the ordering keys
topsort 5 => qw(a b ab t uu g h aa aac);
==> a aa aac ab b
- return the selected values in the original order
top 5 => qw(a b ab t uu g h aa aac);
==> a b ab aa aac
- use a different ordering
For instance comparing the keys as numbers, using the locale configuration or in reverse order:
rnkeytop { length $_ } 3 => qw(a ab aa aac b t uu g h);
==> ab aa aac
rnkeytopsort { length $_ } 3 => qw(a ab aa aac b t uu g h);
==> aac ab aa
A prefix is used to indicate the required ordering:
(no prefix)
lexicographical ascending order
r
lexicographical descending order
l
lexicographical ascending order obeying locale configuration
r
lexicographical descending order obeying locale configuration
n
numerical ascending order
rn
numerical descending order
i
numerical ascending order but converting the keys to integers first
ri
numerical descending order but converting the keys to integers first
u
numerical ascending order but converting the keys to unsigned integers first
ru
numerical descending order but converting the keys to unsigned integers first
The full list of available functions is:
top ltop ntop itop utop rtop rltop rntop ritop rutop
keytop lkeytop nkeytop ikeytop ukeytop rkeytop rlkeytop rnkeytop
rikeytop rukeytop
topsort ltopsort ntopsort itopsort utopsort rtopsort rltopsort
rntopsort ritopsort rutopsort
keytopsort lkeytopsort nkeytopsort ikeytopsort ukeytopsort
rkeytopsort rlkeytopsort rnkeytopsort rikeytopsort rukeytopsort
Download (0.042MB)
Added: 2007-07-18 License: Perl Artistic License Price:
831 downloads
File::Sort 1.01
File::Sort is a Perl module to sort a file or merge sort multiple files. more>>
File::Sort is a Perl module to sort a file or merge sort multiple files.
SYNOPSIS
use File::Sort qw(sort_file);
sort_file({
I => [qw(file_1 file_2)],
o => file_new, k => 5.3,5.5rn, -t => |
});
sort_file(file1, file1.sorted);
This module sorts text files by lines (or records). Comparisons are based on one or more sort keys extracted from each line of input, and are performed lexicographically. By default, if keys are not given, sort regards each input line as a single field. The sort is a merge sort. If you dont like that, feel free to change it.
Options
The following options are available, and are passed in the hash reference passed to the function in the format:
OPTION => VALUE
Where an option can take multiple values (like I, k, and pos), values may be passed via an anonymous array:
OPTION => [VALUE1, VALUE2]
Where the OPTION is a switch, it should be passed a boolean VALUE of 1 or 0.
This interface will always be supported, though a more perlish interface may be offered in the future, as well. This interface is basically a mapping of the command-line options to the Unix sort utility.
I INPUT
Pass in the input file(s). This can be either a single string with the filename, or an array reference containing multiple filename strings.
c
Check that single input fle is ordered as specified by the arguments and the collating sequence of the current locale. No output is produced; only the exit code is affected.
m
Merge only; the input files are assumed to already be sorted.
o OUTPUT
Specify the name of an OUTPUT file to be used instead of the standard output.
u
Unique: Suppresses all but one in each set of lines having equal keys. If used with the c option check that there are no lines with consecutive lines with duplicate keys, in addition to checking that the input file is sorted.
y MAX_SORT_RECORDS
Maximum number of lines (records) read before writing to temp file. Default is 200,000. This may eventually change to be kbytes instead of lines. Lines was easier to implement. Can also specify with MAX_SORT_RECORDS environment variable.
F MAX_SORT_FILES
Maximum number of temp files to be held open at once. Default to 40, as older Windows ports had quite a small limit. Can also specify with MAX_SORT_FILES environment variable. No temp files will be used at all if MAX_SORT_RECORDS is never reached.
D
Send debugging information to STDERR. Behavior subject to change.
The following options override the default ordering rules. When ordering options appear independent of any key field specifications, the requested field ordering rules are applied globally to all sort keys. When attached to a specific key (see k), the specified ordering options override all global ordering options for that key.
d
Specify that only blank characters and alphanumeric characters, according to the current locale setting, are significant in comparisons. d overrides i.
f
Consider all lower-case characters that have upper-case equivalents, according to the current locale setting, to be the upper-case equivalent for the purposes of comparison.
i
Ignores all characters that are non-printable, according to the current locale setting.
n
Does numeric instead of string compare, using whatever perl considers to be a number in numeric comparisons.
r
Reverse the sense of the comparisons.
b
Ignore leading blank characters when determining the starting and ending positions of a restricted sort key. If the b option is specified before the first k option, it is applied to all k options. Otherwise, the b option can be attached indepently to each field_start or field_end option argument (see below).
t STRING
Use STRING as the field separator character; char is not considered to be part of a field (although it can be included in a sort key). Each occurrence of char is significant (for example, delimits an empty field). If t is not specified, blank characters are used as default field separators; each maximal non-empty sequence of blank characters that follows a non-blank character is a field separator.
X STRING
Same as t, but STRING is interpreted as a Perl regular expression instead. Do not escape any characters (/ characters need to be escaped internally, and will be escaped for you).
The string matched by STRING is not included in the fields themselves, unless demanded by perls regex and split semantics (e.g., regexes in parentheses will add that matched expression as an extra field). See perlre and "split" in perlfunc.
R STRING
Record separator, defaults to newline.
k pos1[,pos2]
The keydef argument is a restricted sort key field definition. The format of this definition is:
field_start[.first_char][type][,field_end[.last_char][type]]
where field_start and field_end define a key field restricted to a portion of the line, and type is a modifier from the list of characters b, d, f, i, n, r. The b modifier behaves like the b option, but applies only to the field_start or field_end to which it is attached. The other modifiers behave like the corresponding options, but apply only to the key field to which they are attached; they have this effect if specified with field_start, field_end, or both. If any modifier is attached to a field_start or a field_end, no option applies to either.
Occurrences of the k option are significant in command line order. If no k option is specified, a default sort key of the entire line is used. When there are multiple keys fields, later keys are compared only after all earlier keys compare equal.
Except when the u option is specified, lines that otherwise compare equal are ordered as if none of the options d, f, i, n or k were present (but with r still in effect, if it was specified) and with all bytes in the lines significant to the comparison. The order in which lines that still compare equal are written is unspecified.
pos +pos1 [-pos2]
Similar to k, these are mostly obsolete switches, but some people like them and want to use them. Usage is:
+field_start[.first_char][type] [-field_end[.last_char][type]]
Where field_end in k specified the last position to be included, it specifes the last position to NOT be included. Also, numbers are counted from 0 instead of 1. pos2 must immediately follow corresponding +pos1. The rest should be the same as the k option.
Mixing +pos1 pos2 with k is allowed, but will result in all of the +pos1 pos2 options being ordered AFTER the k options. It is best if you Dont Do That. Pick one and stick with it.
Here are some equivalencies:
pos => +1 -2 -> k => 2,2
pos => +1.1 -1.2 -> k => 2.2,2.2
pos => [+1 -2, +3 -5] -> k => [2,2, 4,5]
pos => [+2, +0b -1] -> k => [3, 1b,1]
pos => +2.1 -2.4 -> k => 3.2,3.4
pos => +2.0 -3.0 -> k => 3.1,4.0
<<lessSYNOPSIS
use File::Sort qw(sort_file);
sort_file({
I => [qw(file_1 file_2)],
o => file_new, k => 5.3,5.5rn, -t => |
});
sort_file(file1, file1.sorted);
This module sorts text files by lines (or records). Comparisons are based on one or more sort keys extracted from each line of input, and are performed lexicographically. By default, if keys are not given, sort regards each input line as a single field. The sort is a merge sort. If you dont like that, feel free to change it.
Options
The following options are available, and are passed in the hash reference passed to the function in the format:
OPTION => VALUE
Where an option can take multiple values (like I, k, and pos), values may be passed via an anonymous array:
OPTION => [VALUE1, VALUE2]
Where the OPTION is a switch, it should be passed a boolean VALUE of 1 or 0.
This interface will always be supported, though a more perlish interface may be offered in the future, as well. This interface is basically a mapping of the command-line options to the Unix sort utility.
I INPUT
Pass in the input file(s). This can be either a single string with the filename, or an array reference containing multiple filename strings.
c
Check that single input fle is ordered as specified by the arguments and the collating sequence of the current locale. No output is produced; only the exit code is affected.
m
Merge only; the input files are assumed to already be sorted.
o OUTPUT
Specify the name of an OUTPUT file to be used instead of the standard output.
u
Unique: Suppresses all but one in each set of lines having equal keys. If used with the c option check that there are no lines with consecutive lines with duplicate keys, in addition to checking that the input file is sorted.
y MAX_SORT_RECORDS
Maximum number of lines (records) read before writing to temp file. Default is 200,000. This may eventually change to be kbytes instead of lines. Lines was easier to implement. Can also specify with MAX_SORT_RECORDS environment variable.
F MAX_SORT_FILES
Maximum number of temp files to be held open at once. Default to 40, as older Windows ports had quite a small limit. Can also specify with MAX_SORT_FILES environment variable. No temp files will be used at all if MAX_SORT_RECORDS is never reached.
D
Send debugging information to STDERR. Behavior subject to change.
The following options override the default ordering rules. When ordering options appear independent of any key field specifications, the requested field ordering rules are applied globally to all sort keys. When attached to a specific key (see k), the specified ordering options override all global ordering options for that key.
d
Specify that only blank characters and alphanumeric characters, according to the current locale setting, are significant in comparisons. d overrides i.
f
Consider all lower-case characters that have upper-case equivalents, according to the current locale setting, to be the upper-case equivalent for the purposes of comparison.
i
Ignores all characters that are non-printable, according to the current locale setting.
n
Does numeric instead of string compare, using whatever perl considers to be a number in numeric comparisons.
r
Reverse the sense of the comparisons.
b
Ignore leading blank characters when determining the starting and ending positions of a restricted sort key. If the b option is specified before the first k option, it is applied to all k options. Otherwise, the b option can be attached indepently to each field_start or field_end option argument (see below).
t STRING
Use STRING as the field separator character; char is not considered to be part of a field (although it can be included in a sort key). Each occurrence of char is significant (for example, delimits an empty field). If t is not specified, blank characters are used as default field separators; each maximal non-empty sequence of blank characters that follows a non-blank character is a field separator.
X STRING
Same as t, but STRING is interpreted as a Perl regular expression instead. Do not escape any characters (/ characters need to be escaped internally, and will be escaped for you).
The string matched by STRING is not included in the fields themselves, unless demanded by perls regex and split semantics (e.g., regexes in parentheses will add that matched expression as an extra field). See perlre and "split" in perlfunc.
R STRING
Record separator, defaults to newline.
k pos1[,pos2]
The keydef argument is a restricted sort key field definition. The format of this definition is:
field_start[.first_char][type][,field_end[.last_char][type]]
where field_start and field_end define a key field restricted to a portion of the line, and type is a modifier from the list of characters b, d, f, i, n, r. The b modifier behaves like the b option, but applies only to the field_start or field_end to which it is attached. The other modifiers behave like the corresponding options, but apply only to the key field to which they are attached; they have this effect if specified with field_start, field_end, or both. If any modifier is attached to a field_start or a field_end, no option applies to either.
Occurrences of the k option are significant in command line order. If no k option is specified, a default sort key of the entire line is used. When there are multiple keys fields, later keys are compared only after all earlier keys compare equal.
Except when the u option is specified, lines that otherwise compare equal are ordered as if none of the options d, f, i, n or k were present (but with r still in effect, if it was specified) and with all bytes in the lines significant to the comparison. The order in which lines that still compare equal are written is unspecified.
pos +pos1 [-pos2]
Similar to k, these are mostly obsolete switches, but some people like them and want to use them. Usage is:
+field_start[.first_char][type] [-field_end[.last_char][type]]
Where field_end in k specified the last position to be included, it specifes the last position to NOT be included. Also, numbers are counted from 0 instead of 1. pos2 must immediately follow corresponding +pos1. The rest should be the same as the k option.
Mixing +pos1 pos2 with k is allowed, but will result in all of the +pos1 pos2 options being ordered AFTER the k options. It is best if you Dont Do That. Pick one and stick with it.
Here are some equivalencies:
pos => +1 -2 -> k => 2,2
pos => +1.1 -1.2 -> k => 2.2,2.2
pos => [+1 -2, +3 -5] -> k => [2,2, 4,5]
pos => [+2, +0b -1] -> k => [3, 1b,1]
pos => +2.1 -2.4 -> k => 3.2,3.4
pos => +2.0 -3.0 -> k => 3.1,4.0
Download (0.032MB)
Added: 2007-04-30 License: Perl Artistic License Price:
909 downloads
SortImagesGUI 1.2.0
This little Java program helps to sort your images from digital cameras. more>>
This little Java program helps to sort your images from digital cameras. It reads the EXIF-Header of the JPEG-Files an copies the images from the source dir to a centralized target dir sorted by year, month and day.
The files are renamed to represent their capture date and time. So you will have a Image repository sorted by capture date of the images.
Additionally some of the image meta informations will be stored in a database along with the MD5 hash of the image as primary key. SortImages check each image beforce copying if its already in the database. If not, the image will sorted into the appropriate folder.
<<lessThe files are renamed to represent their capture date and time. So you will have a Image repository sorted by capture date of the images.
Additionally some of the image meta informations will be stored in a database along with the MD5 hash of the image as primary key. SortImages check each image beforce copying if its already in the database. If not, the image will sorted into the appropriate folder.
Download (0.22MB)
Added: 2006-01-14 License: GPL (GNU General Public License) Price:
1378 downloads
Archive sort 0.1
Archive sort is a bash script that sorts directories into manageable 4.4GB directories for the purpose of archiving onto DVDs. more>>
Archive sort is a bash script that sorts directories into manageable 4.4GB directories for the purpose of archiving onto DVDs.
It is useful if you have several tens or hundreds of GBs of data to archive. It can also be configured to sort into 700MB directories for archiving onto CDs.
Usage: ./archive-sort [-h] [-s SIZE] [-t] [-v] SOURCE DEST
Archive files from directory DEST to new directory SOURCE in 4.4GB chunks,
or any SIZE specified by the user.
This script has not been tested extensively, so it is recommended that you make a copy of the directory you want to archive, then run the script on that directory. Always use the -t (test) option first and carefully read the output before using the script.
Optional arguments.
-h Print this help message.
-s Size of the archive media (default 4.4 GB)
-t Test run with verbose messages.
-v Verbose
Examples:
First cd to directory containing directories to be archived:
cd /home/user/archive
archive-sort . ../disc01
This is useful if you have several large directories under /home/user/archive, but no files. The archive directory will not be included in disc01.
If you have a directory full of lots of files, then cd to the parent directory of the directory that needs to be archived:
cd /home/user
archive-sort archive disc01
<<lessIt is useful if you have several tens or hundreds of GBs of data to archive. It can also be configured to sort into 700MB directories for archiving onto CDs.
Usage: ./archive-sort [-h] [-s SIZE] [-t] [-v] SOURCE DEST
Archive files from directory DEST to new directory SOURCE in 4.4GB chunks,
or any SIZE specified by the user.
This script has not been tested extensively, so it is recommended that you make a copy of the directory you want to archive, then run the script on that directory. Always use the -t (test) option first and carefully read the output before using the script.
Optional arguments.
-h Print this help message.
-s Size of the archive media (default 4.4 GB)
-t Test run with verbose messages.
-v Verbose
Examples:
First cd to directory containing directories to be archived:
cd /home/user/archive
archive-sort . ../disc01
This is useful if you have several large directories under /home/user/archive, but no files. The archive directory will not be included in disc01.
If you have a directory full of lots of files, then cd to the parent directory of the directory that needs to be archived:
cd /home/user
archive-sort archive disc01
Download (0.006MB)
Added: 2006-07-24 License: GPL (GNU General Public License) Price:
1188 downloads
Secleted [ 0 ] software to compare
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above sorted search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed