How can I sort the $item type based on the order? This is what I currently have:
$order = ['AA', 'zl', 'Dr', 'co', 'og'];
$items->sort(
function ($a, $b) use ($order) {
return strcmp($b->type, $a->type) // how do I apply the order here?
?: strcmp($b->date, $a->date);
}
);
Basically it's a two column sort where it first sorts by type and then sorts by date. The type would be sorted using the array order rather than the typical alphabetical order.