From b3839d7e7a7a1248570223e6bcf37f1d73c580df Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 23 Mar 2015 17:44:21 -0700 Subject: [PATCH] handle undefined when sorting quick help since undefined is neither less than nor greater than anything in Javascript, the sort function was treating it as equal to everything, causing inconsistent behavior, depending on the sort algorithm of the browser. This ensures undefined elements are sorted last in the sequence. --- IPython/html/static/base/js/keyboard.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IPython/html/static/base/js/keyboard.js b/IPython/html/static/base/js/keyboard.js index 474b24088..fe02abbbb 100644 --- a/IPython/html/static/base/js/keyboard.js +++ b/IPython/html/static/base/js/keyboard.js @@ -244,13 +244,13 @@ define([ } } help.sort(function (a, b) { - if (a.help_index > b.help_index){ + if (a.help_index === b.help_index) { + return 0; + } + if (a.help_index === undefined || a.help_index > b.help_index){ return 1; } - if (a.help_index < b.help_index){ - return -1; - } - return 0; + return -1; }); return help; };