I have a multidimensional array in php, and I want to naturally sort the array based on key value. The array in question:
Asked 25 Oct, 17 at 05:24 AM
Tim MartinHi Tim,
There is a little modification in the code, you can use this updated code with better sorting:
$order = [ 'small' => 0, 'medium' => 1, 'large' => 2, 's-m' => 3, 'm-l' => 4, 'xl' => 5 ];
if ($item1['width'] == $item2['width']) return 0;
return $order[$item1['width']] < $order[$item2['width']] ? -1 : 1;
});