I have this array:
$po = array (
5 => '8',
6 => '10',
7 => '12',
8 => '41',
12 => '42',
9 => '43',
10 => '44',
11 => '45',
1 => 'L',
0 => 'M',
4 => 'S',
2 => 'XL',
3 => 'XXL',
13 => 'XXS'
)
I need to have it sorted this way:
- All numeric first asc
- All leters by this order:
$order = ['XXS','XS','S','M','L','XL','XXL'];
So far I have this code taken from internet examples:
$sort_first = array('XXS','XS','S','M','L','XL','XXL');
usort($poval, function ($a, $b) use ($sort_first) {
$posA = array_search($a, $sort_first);
$posB = array_search($b, $sort_first);
return $posA - $posB;
});
but numeric values are not OK.. This is export after reordering:
$po = array (
0 => '8',
1 => '45',
2 => 'XXS',
3 => '43',
4 => '44',
5 => '42',
6 => '10',
7 => '12',
8 => '41',
9 => 'S',
10 => 'M',
11 => 'L',
12 => 'XL',
13 => 'XXL'
)
How can I do that? Thanks for your time