Home : Products : Links 2.0 : Customization :

Products: Links 2.0: Customization: Re: [SevenSpirits] How to sort by custom field?: Edit Log

Here is the list of edits for this post
Re: [SevenSpirits] How to sort by custom field?
After much searching and testing, found the answer at perlmonks.com. The second routine now has this:

Code:
sub build_birthday_list_2 {
#-----------------------------
my @data;
my %seen;
my $path = "/big/dom/xvmcoc/www/members";
open (DB, "<$path/birthday_list.txt") or &cgierr ("Unable to open output database.\nReason: $!"); open (DBBDAY, ">$path/birthday_list_2.txt") or &cgierr ("Unable to open output database.\nReason: $!");
@text = <DB>;
close (DB);
my @sorted = map { $_->[0] }
sort { $a->[0] <=> $b->[0] ||
$a->[1] <=> $b->[1];
}
map { [ $_, join "", reverse (split /-/) ] }
@text;
foreach $line(@sorted) {
$line =~ s/\*//g;
$line =~ s/\|/ /g;
print DBBDAY "$line";
}
close DBBDAY;
}


Which produces this:

Quote:

1-1 Julie Wakefield
1-3 Sarah Nichols
1-6 Kaleb Brown
1-7 Thelma Cole
1-7 Lorraine Brock
1-7 Jane Rollins



Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Sep 2, 2008, 10:48 PM

Edit Log: