2

I wand to sort a 3-dimension array in Perl. The elements of the array are in the form:

$arr_3d[indA][indB][indC] , and each element for indC=1 is a number

What I need is, for a given value of indA, sort all the sub-arrays indexed/defined by indB, with the decreasing order of the value of $arr_3d[indA][indB][indC=1],.

e.g. for an 1x2x2 array if:

$arr_3d[1][1][1] = 1
$arr_3d[1][1][2] = 4
$arr_3d[1][2][1] = 2
$arr_3d[1][2][2] = 3

Then after sorting :

$arr_3d[1][1][1] = 2
$arr_3d[1][1][2] = 3
$arr_3d[1][2][1] = 1
$arr_3d[1][2][2] = 4

So after sorting the sub-arrays $arr_3d[1][1] and $arr_3d[1][2] are swapped. Sorry for the messed up description.. Any ideas?

Regards, Giorgos

4

1 に答える 1