I have my data like this
I am trying to sort it like this
$initialArrayBTC.sort(function (a, b) {
return b.q - a.q //Trying to sort is on the base of "q" in descending order
});
But this does not seem to work although I looked through many stackoverflow answers. Can anyone help me what might be the issue?
EDIT This is my all data inside the object
SAMPLE CODE
var $initialArrayBTC = [];
$initialArrayBTC['A'] = {
q: "3598"
};
$initialArrayBTC['B'] = {
q: "123"
};
$initialArrayBTC['C'] = {
q: "9999"
};
console.log($initialArrayBTC);
$initialArrayBTC.sort(function(a, b) {
return b.q - a.q //Trying to sort is on the base of "q" in descending order
});
console.log($initialArrayBTC);