in reply to Sorting Issue

It looks like you're trying to sort the columns independently, and then recombine them visually.

The following produces the results you desire, although it assumes that the left and right columns are the same length.

#!/usr/bin/perl use strict; use warnings; my (@left, @right); while(<DATA>) { chomp; my ($left, $right) = split /,/; push(@left, $left); push(@right, $right); } @left = sort { $a <=> $b } @left; @right = sort { $a <=> $b } @right; print "$left[$_],$right[$_]\n" for 0 .. $#left; __DATA__ 10,20 30,10 20,70 70,80 40,90 90,100 50,50

Hope this helped,
-v.

"Perl. There is no substitute."

Replies are listed 'Best First'.
Re^2: Sorting Issue
by farhan (Novice) on Jul 27, 2006 at 11:36 UTC
    Hello Monks,

    Thanks you Guys. It is an excellent forum. I was not expecting prompt reponse.

    Thanks,
    Farhan