I have a small Perl script that presents the info from a flatfile database, but I would like it to sort on one field, then sub-sort on another. But I'm not sure how to do a sort at all! What I have so far, doesn't work but it is:
[tt]
while (($line = &read_file("FILE1"
) && ($counter < 200)) {
# split the fields at the | character
@tabledata = split(/\s*\|\s*/,$line ,$fields);
my @tabledata;
my @sort_indexes;
my @sorted;
@sorted =
map {$_->[3]} (
sort {$a->[3] <=> $b->[3]} (
map {[$_, shift(@sort_indexes)]} @tabledata));
[/tt]
I'm trying to sort on the third field ($tabledata[3]) but would also like to sort on $tabledata[8]. I'm not a programmer so any help is appreciated. Thanks!
Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
[tt]
while (($line = &read_file("FILE1"
# split the fields at the | character
@tabledata = split(/\s*\|\s*/,$line ,$fields);
my @tabledata;
my @sort_indexes;
my @sorted;
@sorted =
map {$_->[3]} (
sort {$a->[3] <=> $b->[3]} (
map {[$_, shift(@sort_indexes)]} @tabledata));
[/tt]
I'm trying to sort on the third field ($tabledata[3]) but would also like to sort on $tabledata[8]. I'm not a programmer so any help is appreciated. Thanks!
Don
don@ctagroup.org
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)