You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
412 B
23 lines
412 B
4 years ago
|
# `sortKeys()`
|
||
|
|
||
|
The sortKeys method sorts the collection by the keys of the underlying associative array:
|
||
|
|
||
|
```js
|
||
|
const collection = collect({
|
||
|
id: 10,
|
||
|
first: 'Sadio',
|
||
|
last: 'Mané',
|
||
|
});
|
||
|
|
||
|
const sorted = collection.sortKeys();
|
||
|
|
||
|
sorted.all();
|
||
|
|
||
|
// {
|
||
|
// first: 'Sadio',
|
||
|
// id: 10,
|
||
|
// last: 'Mané',
|
||
|
// }
|
||
|
```
|
||
|
|
||
|
[View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/sortKeys.js)
|