From 4c9f3aee7422d0d26c6bcb8c5d1b21dd63c87996 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 27 Jul 2014 13:05:26 -0700 Subject: [PATCH] Make `baseSortedIndex` handle `NaN` correctly when comparing numbers. --- lodash.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lodash.js b/lodash.js index 40ab5f20c..ed27130bb 100644 --- a/lodash.js +++ b/lodash.js @@ -2400,10 +2400,16 @@ high = array ? array.length : low; value = iterator(value); + var hintNum = typeof value == 'number' || + (value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number'); + while (low < high) { var mid = (low + high) >>> 1, computed = iterator(array[mid]); + if (hintNum && typeof computed != 'undefined') { + computed = +computed || 0; + } if (retHighest ? computed <= value : computed < value) { low = mid + 1; } else {