public function sortBy($key) { $this->items = $this->items->sortBy(function ($item) use($key) { return $item->{$key}; }); return $this; }