From e4c4300a064b9bf21bfcf112088fe9cd0f46a049 Mon Sep 17 00:00:00 2001 From: Chris Baynes Date: Sat, 31 Mar 2012 11:05:47 +0200 Subject: [PATCH] Allow sortBy to handle undefined values. --- underscore.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/underscore.js b/underscore.js index 44226a07c..00ca13d4a 100644 --- a/underscore.js +++ b/underscore.js @@ -270,6 +270,8 @@ }; }).sort(function(left, right) { var a = left.criteria, b = right.criteria; + if (_.isUndefined(a)) return 1; + if (_.isUndefined(b)) return -1; return a < b ? -1 : a > b ? 1 : 0; }), 'value'); };