Sort array from a Query



I have 2 tables (simplified):

coasters (ID,BREWERY_CODE, etc)
breweries (BREWERY_CODE, BREWERY)

For each brewery I want to count how many coasters are there in table
"coasters" (up to here it works fine) and then I want to show them
ordered by quantity (that's my problem):

The following is the piece of code.
......
$search_breweries = mysql_query("SELECT BREWERY_CODE, BREWERY FROM
breweries");
$i = 0;
while ($row = mysql_fetch_array($search_breweries, MYSQL_NUM)) {
$breweries[$i][0] = $row[0];
$breweries[$i][1] = $row[1];
$key_brewery = $row[0];
$count_coasters_brewery = mysql_query("SELECT COUNT(*) FROM coasters
WHERE BREWERY_CODE = $key_brewery");
$breweries[$i][2] = mysql_result($count_coasters_brewery,0,0);
$i = $i + 1;
}

I suppose I have to assign everything to an array and then sort it, but
I don't know how.

Any help will be welcomed.
Bettina

.



Relevant Pages

  • Re: Smells Recycled
    ... > Probably because most of the breweries have greatly diminished if not ... I was really sad when S&N (what does the 'S' stand for ... Sheila ... Prev by Date: ...
    (soc.culture.scottish)
  • Re: Good Article in NYTimes about Portland,OR
    ... Actually, it said 28 breweries. ... But you can do your own count, and not just for Portland. ... --Jeff Frane ... Prev by Date: ...
    (rec.food.drink.beer)
  • Re: Smells Recycled
    ... Probably because most of the breweries have greatly diminished if not ... I was really sad when S&N (what does the 'S' stand for ... bought over the Caley Brewery. ... Prev by Date: ...
    (soc.culture.scottish)