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