You have to change string to date or int in this example:
$collection->sortBy(function ($item) {
return strtotime($item->created_at);
});
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi Guys I found some strange behaviour when the data deleted, it not sort same as before
This is the actual data
Then after I delete the purchase id 4898 and refresh it become
$collection->sortBy('expiry_date')
Anyone know how this happend?
Please or to participate in this conversation.