EExamplePanel: make sure items are sorted alphabetically

This commit is contained in:
rolux 2012-06-22 09:54:27 +02:00
parent 422258448e
commit e8f3caff8e

View file

@ -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;
};