I have the following JavaScript object:
The output of console.log(myObject) is:
[Object, Object]
0: Object
data: Array[19]
label: "Orange"
__proto__: Object
1: Object
data: Array[19]
label: "Black"
__proto__: Object
length: 2
__proto__: Array[0]
I need to sort the object by label
I've tried:
myObject.sort(function(a, b){
return a.label - b.label;
});
Which doesn't seem to work.
Q: How can I sort the object by label?
'Orange' - 'Black'in the console.