|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
551 bytes
|
| Line | |
|---|
| 1 | import { orderBy } from './orderBy.mjs';
|
|---|
| 2 | import { flatten } from '../../array/flatten.mjs';
|
|---|
| 3 | import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
|
|---|
| 4 |
|
|---|
| 5 | function sortBy(collection, ...criteria) {
|
|---|
| 6 | const length = criteria.length;
|
|---|
| 7 | if (length > 1 && isIterateeCall(collection, criteria[0], criteria[1])) {
|
|---|
| 8 | criteria = [];
|
|---|
| 9 | }
|
|---|
| 10 | else if (length > 2 && isIterateeCall(criteria[0], criteria[1], criteria[2])) {
|
|---|
| 11 | criteria = [criteria[0]];
|
|---|
| 12 | }
|
|---|
| 13 | return orderBy(collection, flatten(criteria), ['asc']);
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | export { sortBy };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.