From 520f7c68128bfac7ef827aa70eaa00902a1b4af2 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 13 Apr 2015 09:30:01 -0700 Subject: [PATCH] Ensure `index` in `baseSortByOrder` is an integer. --- lodash.src.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 149b8c854..80ddc321e 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2846,12 +2846,14 @@ * @returns {Array} Returns the new sorted array. */ function baseSortByOrder(collection, iteratees, orders) { - var callback = getCallback(); + var callback = getCallback(), + index = -1; + iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); }); - var result = baseMap(collection, function(value, index) { + var result = baseMap(collection, function(value) { var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); }); - return { 'criteria': criteria, 'index': index, 'value': value }; + return { 'criteria': criteria, 'index': ++index, 'value': value }; }); return baseSortBy(result, function(object, other) {