Skip to content

Commit

Permalink
sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey committed Jun 1, 2021
1 parent 86a3d21 commit 36a362c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ public function set($condition, $object)
return false;
}

public function sort($field)
{
$attributes = $this->attributes;
if (empty($attributes) || !in_array($field, array_keys(reset($attributes)))) {
return;
}
usort($this->_container, function ($item1, $item2) use ($field) {
return $item1[$field] <=> $item2[$field];
});
}

public function offsetSet($offset, $model)
{
if (is_null($offset)) {
Expand Down

0 comments on commit 36a362c

Please sign in to comment.