#!/usr/bin/perl use strict; use warnings; my @item_array = ([1, 2, 20], [2, 3, 15], [3,4,3], [4, 5, 17], [5,6,28], [6,1,23], [1, 7, 1], [2, 7, 4], [3, 7, 9,], [4, 7, 16], [5, 7, 25], [6, 7, 36], ); my @sorted_array = sort { $a->[2] <=> $b->[2] } @item_array; for (@sorted_array) { print join("\t", @$_), "\n"; } #### 1 7 1 3 4 3 2 7 4 3 7 9 2 3 15 4 7 16 4 5 17 1 2 20 6 1 23 5 7 25 5 6 28 6 7 36