function CollectionInterface::sort
Sort the collection by a property, method, or array key with the given sort order.
If $propertyOrMethod is `null`, this will sort by comparing each element.
This will always leave the original collection untouched and will return a new one.
Parameters
string | null $propertyOrMethod The property, method, or array key: to sort by.
Sort $order The sort order for the resulting collection.:
Return value
CollectionInterface<T>
Throws
InvalidPropertyOrMethod if the $propertyOrMethod does not exist on the elements in this collection.
UnsupportedOperationException if unable to call sort() on this collection.
1 method overrides CollectionInterface::sort()
- AbstractCollection::sort in vendor/
ramsey/ collection/ src/ AbstractCollection.php
File
-
vendor/
ramsey/ collection/ src/ CollectionInterface.php, line 139
Class
- CollectionInterface
- A collection represents a group of values, known as its elements.
Namespace
Ramsey\CollectionCode
public function sort(?string $propertyOrMethod = null, Sort $order = Sort::Ascending) : self;