in reply to Sorting by column

You know what cmp returns, right? When there's a tie, it returns zero. So when it's zero, you want to compare the 3rd columns.
@array = sort { my @cols_a = split /\s/, $a; my @cols_b = split /\s/, $b; $cols_a[1] cmp $cols_b[1] || $cols_a[2] cmp $cols_b[2] } @array;

Replies are listed 'Best First'.
Re^2: Sorting by column
by DrHyde (Prior) on Sep 16, 2009 at 09:48 UTC
    Or for a more general solution that doesn't require adding || after || after || and which uses data to drive the sort instead of hard-coding it, check out Sort::MultipleFields. You'll need to turn your data into an array of hashrefs first and then back again afterwards.