Skip to content
Advertisement

How do I sort a Laravel Collection by multiple properties with both asc and desc?

If I have an IlluminateSupportCollection, how do I sort by multiple properties with both asc and desc? (This is a simple hypothetical – not at all looking for tips on query building.)

JavaScript

Advertisement

Answer

Whoever uses this, just keep in mind – you’ll need to tweak it depending if your using collection of objects or associative arrays. Should be an easy tweak. Just change the $a[]/$b[] stuff to $a-> and $b->

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement