in reply to Sorting a CSV file

Hi,

You might want to look at Text::CSV for parsing your csv file. It could make things a bit simpler.

And then, as McDarren says, Date::Calc would be quite helpful for your sort. Perhaps convert it to a unixtime format and then perform the sort.

A sort sub to get the job done:
# Store your values in a hash of hashes # $kols{line1} = { date => 12-12-06, bits => 12, ... } my $orderby = "date" # or "bits, ..." my $updown = "DESC" # or "ASC" foreach (sort { &mysort($updown) } keys %kols) { } # end-foreach sub mysort { my ($direction) = @_; if ($direction eq "DESC") { $kols{$b}{$orderby} <=> $kols{$a}{$orderby} || $kols{$b}{$orderby} cmp $kols{$a}{$orderby} } # end-if else { $kols{$a}{$orderby} <=> $kols{$b}{$orderby} || $kols{$a}{$orderby} cmp $kols{$b}{$orderby} } # end-else } # end-sub

Cheers.