* Creates an array of elements, sorted in ascending order by the results of * running each element in a collection through `iteratee`. This method performs * a stable sort, that is, it preserves the original sort order of equal elements. * The `iteratee` is bound to `thisArg` and invo
(collection, iteratee, thisArg)
| 8595 | * // => ['barney', 'fred', 'pebbles'] |
| 8596 | */ |
| 8597 | function sortBy(collection, iteratee, thisArg) { |
| 8598 | if (collection == null) { |
| 8599 | return []; |
| 8600 | } |
| 8601 | if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { |
| 8602 | iteratee = null; |
| 8603 | } |
| 8604 | var index = -1; |
| 8605 | iteratee = getCallback(iteratee, thisArg, 3); |
| 8606 | |
| 8607 | var result = baseMap(collection, function(value, key, collection) { |
| 8608 | return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; |
| 8609 | }); |
| 8610 | return baseSortBy(result, compareAscending); |
| 8611 | } |
| 8612 | |
| 8613 | /** |
| 8614 | * This method is like `_.sortBy` except that it can sort by multiple iteratees |
nothing calls this directly
no test coverage detected