I have a PHP Array of Cities and States. I want the end result to be sorted alphabetically by State and then by City.
Start With:
Location[0]['state'] => 'Ohio',
Location[0]['city'] => 'Columbus',
Location[1]['state'] => 'Illinois',
Location[1]['city'] => 'Chicago',
Location[2]['state'] => 'Ohio',
Location[2]['city'] => 'Cleveland',
Location[3]['state'] => 'Illinois',
Location[3]['city'] => 'Springfield'
The end result should be sorted like this:
Location[0]['state'] => 'Illinois',
Location[0]['city'] => 'Chicago',
Location[1]['state'] => 'Illinois',
Location[1]['city'] => 'Springfield',
Location[2]['state'] => 'Ohio',
Location[2]['city'] => 'Cleveland',
Location[3]['state'] => 'Ohio',
Location[3]['city'] => 'Columbus'
as of 5.3:
ADDED: it is more easy with strcmp