in reply to Sorting Issue
Since your requirements about the output are a bit vague, the output of this isn't exactly the same as yours. This outputs two columns of sorted numbers, and the right number of each column is never less than the number on its left.
open my $fd, '<', 'file' or die "open: $!"; my @all; while (<$fd>) { chomp; push @all, split /,/; } close $fd; @all = sort { $a <=> $b } @all; my @result; for (my $i = 0; $i < @all; $i+=2) { push @result, "$all[$i]," . ( defined $all[$i+1] ? $all[$i+1] : '' ); } print "$_\n" for @result;
--
David Serrano
|
|---|