Given an array of objects like this:
objects = [
{ id: \'aaaa\', description: \'foo\' },
{ id: \'bbbb\', description: \'bar\' },
{ id: \'cccc\', descri
Try this:
objects.sort(function(a, b){
return order.indexOf(a.id) - order.indexOf(b.id)
});
Assuming the variables are like you declared them in the question, this should return:
[
{ id: 'bbbb', description: 'bar' },
{ id: 'aaaa', description: 'foo' },
{ id: 'cccc', description: 'baz' }
];
(It actually modifies the objects variable)