i need through all the elements of a two-dimensional array, and sort items. please help me!!
should trace out in this:
0
1
2
3
4
5
6
7
8
9
9
that this is not bad, so I turn to you I need help
my code:
var n:Array;var aux:Number = 0;
// Array
n =
[[3,1,2,4],
[6,5,7,8],
[0,9,9,1]]
trace(" 0 1 2 3");
trace(" 0[x,x,x,x]");
trace(" 1[x,x,x,x]");
trace(" 2[x,x,x,x]");
trace("------------------------");
trace("-----Original Array-----");
for(var a:Number = 0; a<n.length; a++)
{
trace(" [" + n[a] + "]");
}
trace("------------------------");
trace("Size array: " + n.length);
trace("------------------------");
trace("Position of each element: ");
trace("Position 0,0:" + " " + n[0][0]);
trace("Position 0,1:" + " " + n[0][1]);
trace("Position 0,2:" + " " + n[0][2]);
trace("Position 0,3:" + " " + n[0][3]);
trace("Position 1,0:" + " " + n[1][0]);
trace("Position 1,1:" + " " + n[1][1]);
trace("Position 1,2:" + " " + n[1][2]);
trace("Position 1,3:" + " " + n[1][3]);
trace("Position 2,0:" + " " + n[2][0]);
trace("Position 2,1:" + " " + n[2][1]);
trace("Position 2,2:" + " " + n[2][2]);
trace("Position 2,3:" + " " + n[2][3]);
trace("------------------------");
trace(" ---Ordered array--- ");
for(var i:Number = 0; i<n.length; i++)
{
for(var j:Number = 0; j<n.length; j++)
{
for(var k:Number = 0; k<n.length; k++)
{
for(var l:Number = 0; l<n.length; l++)
{
if(n*[j]>n[k][l])
{
aux = n*[j];
n*[j] = n[j][l];
n[k][l] = aux;
}
}
}
}
}
for(var q:Number = 0; q<n.length; q++)
{
for(var w:Number = 0; w<n.length; w++)
{
trace(n[q][w]);
}
}