Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Sorting Multidimensional Arrays

Sorting multidimensional arrays



2:38 pm on Sep 26, 2006 (gmt 0)

10+ Year Member


I am trying to analyse stored customer enquiries by month and country of origin. The total enquiries for each country and month are contained in an array in the format...


...where $x is the month (1-12) and $z is a country code (1-200).

I need to list the contents of the array by month, in ascending order, and by the value of the country column, in descending order.

I have spent a day trying to get my head around the various array sort functions and failed miserably.

HELP please! thanks in anticipation.


3:36 pm on Sep 26, 2006 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

take a look at this

$country[0] = array(5,98);
$country[1] = array(3,11);
$country[2] = array(2,199);
$country[3] = array(1,43);
$country[4] = array(4,126);

echo '<p><pre>before sort:<br>';
echo '</pre>';


echo '<p><pre>after sort:<br>';
echo '</pre>';



Featured Threads

Hot Threads This Week

Hot Threads This Month