Skip to content

Commit

Permalink
IHF: multiarray_sort_by helper readme added.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivanov committed Mar 2, 2017
1 parent 4ba68c3 commit 47dc689
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ $array = [
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
];
$sorted = multiarray_sort_by($array, 'name', 'model')
$sorted = multiarray_sort_by($array, 'name', 'model');
// [
// ['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
Expand All @@ -113,6 +113,25 @@ $sorted = multiarray_sort_by($array, 'name', 'model')
// ]
```
Optionally, you can set required sort order:
```php
$array = [
['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
];
$sorted = multiarray_sort_by($array, 'name', SORT_ASC, 'model', SORT_DESC);
// [
// ['name' => 'BMW', 'model' => 'X6', 'price' => 77000],
// ['name' => 'Mercedes-Benz', 'model' => 'GLS', 'price' => 120000],
// ['name' => 'Mercedes-Benz', 'model' => 'GLE Coupe', 'price' => 110000],
// ['name' => 'Porsche', 'model' => 'Cayenne', 'price' => 117000],
// ]
```
## Artisan
#### `call_in_background()`
Expand Down

0 comments on commit 47dc689

Please sign in to comment.