New to PHP, I need to sort a large 2 dimensional array by values in the
2nd dimension
I have an array of sales data in an array, and I want to be able to sort
the 1st dimension of the array by values in the 2nd dimension. My code
prints sales data in order of the 1st dimension of the array, so all I
need to do is change the order of the dimension to change the output.
Here's my array:
$salesdata = array
(
array
(
"1", //store number
"1580", //sales
"1151", //plan sales
"1441", //ly sales
"508", //sgp
"561", //plan sgp
"621", //ly sgp
"38", //tix
"-10", //tix var
),
array
(
"2", //store number
"1493", //sales
"1520", //plan sales
"2040", //ly sales
"610", //sgp
"1106", //plan sgp
"483", //ly sgp
"62", //tix
"0", //tix var
),
array
(
"3", //store number
"1987", //sales
"989", //plan sales
"1030", //ly sales
"997", //sgp
"482", //plan sgp
"554", //ly sgp
"63", //tix
"13", //tix var
),
)
I want to be able to sort by any value, but I can work out that part.
Let's say I wanted to sort by sales, how would I do that?
Thanks!
No comments:
Post a Comment