Apply new format to snippets and template

This commit is contained in:
Angelos Chalaris
2020-09-15 16:28:04 +03:00
parent 040efd4380
commit 53c16dbf65
401 changed files with 969 additions and 950 deletions

View File

@ -5,8 +5,8 @@ tags: object,array,intermediate
Returns a sorted array of objects ordered by properties and orders.
Uses `Array.prototype.sort()`, `Array.prototype.reduce()` on the `props` array with a default value of `0`, use array destructuring to swap the properties position depending on the order passed.
If no `orders` array is passed it sort by `'asc'` by default.
- Uses `Array.prototype.sort()`, `Array.prototype.reduce()` on the `props` array with a default value of `0`, use array destructuring to swap the properties position depending on the order passed.
- If no `orders` array is passed it sort by `'asc'` by default.
```js
const orderBy = (arr, props, orders) =>
@ -25,4 +25,4 @@ const orderBy = (arr, props, orders) =>
const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }];
orderBy(users, ['name', 'age'], ['asc', 'desc']); // [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}]
orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}]
```
```