use Data::Dumper; my @array = (); $array[0] = [1]; $array[2] = [2]; @array = sort { $$a[0] cmp $$b[0]} @array; print Dumper \@array;