Answer the question
In order to leave comments, you need to log in
How to sort values in ascending order for an object by a specific field?
I get our object:
$partnerProductStatuses = PartnerProductsStatus::all();
id name count partner_id
7 sredn 30 53
6 mnogo 50 53
8 maloo 10 53
function cmp($a, $b)
{
return strcmp($a->count, $b->count);
}
usort($partnerProductStatuses, array($partnerProductStatuses,'cmp'));
Answer the question
In order to leave comments, you need to log in
And why not sort at the sampling level?->orderBy('count', 'desc')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question