So I know that there are dozens of posts on here that describe how to sort a multidimensional object, but I have not been able to find one that fits my needs.
All those solutions are based on an object like this:
[{id: 1, value: 'aaa'},{id: 40, value: 'bbbb'}]
My object looks like this:
buttons: {
confirm: {
class: 'btn btn-primary',
value: 'Opslaan',
order: 1
},
cancel: {
class: 'btn btn-default',
value: 'Annuleer',
order: 10
}
delete: {
class: 'btn btn-danger',
value: 'Verwijder',
order: 2
}
},
Naturally, I want to sort this so that the outcome is: confirm, delete, cancel. I have tried this (which I expected not to work):
this.options.buttons.sort ( function ( a, b ) {
return a.order - b.order;
});
But that gave me an Uncaught TypeError: undefined is not a function
Any help is much appreciated!