Illuminate\Support\Collection::sort PHP Method

sort() public method

Sort through each item with a callback.
public sort ( callable $callback = null ) : static
$callback callable
return static
    public function sort(callable $callback = null)
    {
        $items = $this->items;
        $callback ? uasort($items, $callback) : asort($items);
        return new static($items);
    }

Usage Example

Beispiel #1
0
 /**
  * @param string $level
  *
  * @return \Illuminate\Support\Collection
  */
 public function get($level = '*')
 {
     $this->messages->sort(function ($a, $b) {
         return $b['sort'] - $a['sort'];
     });
     return $level !== '*' ? $this->filterNotifications($level) : $this->messages;
 }
All Usage Examples Of Illuminate\Support\Collection::sort