From 3740b498acceecacde5bcf99f28572adbbcffa6a 2015-03-25 18:08:24 From: Min RK Date: 2015-03-25 18:08:24 Subject: [PATCH] Backport PR #8131: 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. closes #8089 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; };