From 320fde2600c5e2cfb3c61784828295e18151a752 2015-03-24 00:44:21 From: Min RK Date: 2015-03-24 00:44:21 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. --- diff --git a/IPython/html/static/base/js/keyboard.js b/IPython/html/static/base/js/keyboard.js index 474b240..fe02abb 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){ - return 1; + if (a.help_index === b.help_index) { + return 0; } - if (a.help_index < b.help_index){ - return -1; + if (a.help_index === undefined || a.help_index > b.help_index){ + return 1; } - return 0; + return -1; }); return help; };