mercredi 22 août 2018

laravel - sortBy() not working properly

I have collection with subcollections like:

+
+--- name: 1a8 Lorem Ipsum
+
+--- name: 1a2 Lorem Ipsum
+
+--- name: 1a10 Lorem Ipsum

and now I want to sort it by this name:

$collection->sortBy('name')

It should be:

1a2 Lorem Ipsum
1a8 Lorem Ipsum
1a10 Lorem Ipsum

but I'm getting:

1a10 Lorem Ipsum
1a2 Lorem Ipsum
1a8 Lorem Ipsum

Why? I have tried too with $collection->sortBy('name', SORT_NATURAL, false) but it's same effect.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire