http://www.perlmonks.org?node_id=20802

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (arrays)

I want to be able to sort the "double-dimension" array by one of the colums... eg. alphabeticaly by comparing items in column 2 of the array... below some sample data:
$foo[0][0] = "zenia"; $foo[0][1] = "markownikowa"; $foo[0][2] = +"10"; $foo[1][0] = "marek"; $foo[1][1] = "butalski"; $foo[1][2] = +"20"; $foo[2][0] = "teresa"; $foo[2][1] = "parufkowa"; $foo[2][2] = +"90"; $foo[3][0] = "bogumila"; $foo[3][1] = "pierdowa"; $foo[3][2] = +"40"; $foo[4][0] = "genowefa"; $foo[4][1] = "tempawa"; $foo[4][2] = +"50"; First -- let's sort these by the [][1] column... the result should be: marek brutalski 20 zenia markownikowa 10 teresa parufkowa 90 bogumila pierdawa 40 genowefa tempawa 50 sorting by the [][2] column should give us: zenia markownikowa 10 marek brutalski 20 bogumila pierdawa 40 genowefa tempawa 50 teresa parufkowa 90
The manual covers only case of hashes and uses subroutine for comparing items. But how to adopt that for comparing such an array? Thanx in advance... Joustin

Originally posted as a Categorized Question.