MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / sortBy

Function sortBy

lib/web/jshint.js:8597–8611  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

isIterateeCallFunction · 0.85
getCallbackFunction · 0.85
baseMapFunction · 0.85
baseSortByFunction · 0.85

Tested by

no test coverage detected