Sorting a 3D or 4D array
I need to sort a 3D or is it a 4D array, but all the codes i've found are only able to sort the deepest array in each
i.e
Array
(
[0] => Array
(
[0] => Array
(
[name] => 12.jpg
[size] => 5739
)
[1] => Array
(
[name] => 123.jpg
[size] => 4541
)
[2] => Array
(
[name] => ccopy.jpg
[size] => 5739
)
[3] => Array
(
[name] => download (1).jpg
[size] => 8889
)
[4] => Array
(
[name] => download (3).jpg
[size] => 8405
)
[5] => Array
(
[name] => images.jpg
[size] => 5739
)
[6] => Array
(
[name] => 1.gif
[size] => 8405
)
[7] => Array
(
[name] => brdodas.jpeg
[size] => 6829
)
)
[1] => Array
(
[0] => Array
(
[name] => asd.jpg
[size] => 5739
)
[1] => Array
(
[name] => Copy of no-cat-icon.gif
[size] => 6951
)
[2] => Array
(
[name] => no-cat-icon.gif
[size] => 6951
)
)
[2] => Array
(
[0] => Array
(
[name] => Blue hills.jpg
[size] => 28521
)
[1] => Array
(
[name] => Sunset.jpg
[size] => 71189
)
[2] => Array
(
[name] => Water lilies.jpg
[size] => 83794
)
[3] => Array
(
[name] => Winter.jpg
[size] => 105542
)
[4] => Array
(
[name] => download (1).jpg
[size] => 8889
)
[5] => Array
(
[name] => download (3).jpg
[size] => 8405
)
[6] => Array
(
[name] => download.jpg
[size] => 4541
)
)
[3] => Array
(
[0] => Array
(
[name] => Water lilies.jpg
[size] => 83794
)
[1] => Array
(
[name] => Winter.jpg
[size] => 105542
)
[2] => Array
(
[name] => asdas.jpg
[size] => 6168
)
[3] => Array
(
[name] => asdasdas.jpg
[size] => 6868
)
[4] => Array
(
[name] => download (1).jpg
[size] => 8889
)
[5] => Array
(
[name] => download (3).jpg
[size] => 8405
)
[6] => Array
(
[name] => download.jpg
[size] => 4541
)
[7] => Array
(
[name] => thumbnail_6_1316463355.jpg
[size] => 2826
)
)
[4] => Array
(
[0] => Array
(
[name] => Copy of download.jpg
[size] => 4541
)
[1] => Array
(
[name] => download (1).jpg
[size] => 8889
)
[2] => Array
(
[name] => download (2).jpg
[size] => 6829
)
[3] => Array
(
[name] => download (3).jpg
[size] => 8405
)
[4] => Array
(
[name] => download.jpg
[size] => 4541
)
)
)
the sorting function:
usort($datall, 'array_name_sort');
function array_name_sort($a,$b) {
if($a['name']>$b['name']) return 1;
elseif($b['name']>$a['name']) return -1;
else return 0;
}
i know i need to play around with this function to have the output i need, but i do not quite understand how the function work, like how does it determine the values for $a, $b.
if anyone would be kind enough to explain it to me so that i may be able to formulate my own sorting function for this problem, also if there are anyone out there that is familiar with this problem would you be kind enough to explain your algorithm in making the sorting function.
so basically i wish to learn the proper detailed algorithm for sorting such arrays.
Thank You very much.
be kind, i'm used to working with database so i'm not that familiar with arrays, especially arrays this big.
After a css3 rotateX transformation on a div box, it's
height changes on the display, but not in the code. Is there any
way I can get these new dimensions? Safari's element inspector
delimits the surface correctly, but still, in the code, the box has
still a height of 430px instead of the correct 53px. I would
appreciate any help!!