From e8f3caff8e7dc4071a84f102f3d7633fa9ee6267 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 22 Jun 2012 09:54:27 +0200 Subject: [PATCH] EExamplePanel: make sure items are sorted alphabetically --- source/Ox.UI/js/Code/ExamplePanel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/Ox.UI/js/Code/ExamplePanel.js b/source/Ox.UI/js/Code/ExamplePanel.js index 24ca3e30..caf13d9f 100644 --- a/source/Ox.UI/js/Code/ExamplePanel.js +++ b/source/Ox.UI/js/Code/ExamplePanel.js @@ -118,7 +118,9 @@ Ox.ExamplePanel = function(options, self) { return a < b ? -1 : a > b ? 1 : 0; }) : []; items.push(item); - items.length == self.options.examples.length && callback(items); + if (items.length == self.options.examples.length) { + callback(items.sort(sortById)); + } }); }); }); @@ -154,6 +156,10 @@ Ox.ExamplePanel = function(options, self) { that.triggerEvent('select', {id: self.options.selected}); } + function sortById(a, b) { + return a.id < b.id ? -1 : a.id > b.id ? 1 : 0; + } + return that; };