I have a working delivery system that I need to present in alphabetical order sorted by the city, which is the key in a subarray.
This is the array:
array (
'option_3' => array (
'Rio' => '18',
),
'option_4' => array (
'Tokyo' => '20',
),
'option_5' => array (
'Berlim' => '23',
)
)
And it is shown in this table:
<table>
<tr>
<th>ID</th>
<th>Bairro</th>
<th>Valor</th>
<th>Ação</th>
</tr>
[a foreach goes here]
<tr>
<td><?php echo $option_number;?></td>
<td><?php echo $city;?></td>
<td><?php echo $price;?></td>
<td><button type='submit'>Remove</button></td>
</tr>
<table>
This produces the folowing result:
ID City Value Action
3 Rio 18 Remover
4 Tokyo 20 Remover
5 Berlim 23 Remover
But I need it to be sorted by the city:
ID City Value Action
5 Berlim 23 Remover
3 Rio 18 Remover
4 Tokyo 20 Remover
How could I accomplish this?