mmittiga17 has asked for the wisdom of the Perl Monks concerning the following question:
Hi All, I have been trying to find with in Text::CSV a way to sort on 1 column 1 first and then by 44th column. Reading through CPAN module page and googling I can not seem to find a way to sort on multiple fields using Text::CSV. can someone point me in the right direction? Thanks !
here is what I have so far: while( <IN2> ) { chomp; $count++; # skip header next unless $count; my $row; @$row = split( /,/, $_ ); push @$sheet, $row; } foreach my $row ( sort { $a->[0] cmp $b->[0] || $a->[44] cmp $b->[44] +} @$sheet ) { print OUT join( ',', @$row ), "\n"; }
problem is the 45th field can 1 or 001 2 or 002. I need to strip the preceding 00 and then sort. for some reason I notice that in field 45 after sorting it can look like: 1 10 11 17 2 4 5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I sort a CSV file on multiple columns?
by kennethk (Abbot) on Dec 09, 2009 at 18:42 UTC | |
|
Re: How do I sort a CSV file on multiple columns?
by GrandFather (Saint) on Dec 09, 2009 at 22:30 UTC | |
by Tux (Canon) on Dec 10, 2009 at 16:33 UTC | |
|
Re: How do I sort a CSV file on multiple columns?
by redgreen (Priest) on Dec 09, 2009 at 18:42 UTC | |
|
Re: How do I sort a CSV file on multiple columns?
by Tux (Canon) on Dec 09, 2009 at 21:02 UTC | |
|
Re: How do I sort a CSV file on multiple columns?
by gmargo (Hermit) on Dec 09, 2009 at 18:52 UTC | |
|
Re: How do I sort a CSV file on multiple columns?
by mmittiga17 (Scribe) on Dec 09, 2009 at 19:39 UTC | |
by AnomalousMonk (Archbishop) on Dec 09, 2009 at 20:18 UTC | |
by kennethk (Abbot) on Dec 09, 2009 at 20:29 UTC |