If I have an array with objects like this:
percentages_oparea
0:
name: test1
pvalue: 15
1:
name: test2
pvalue: 16
I can sort this in javascript this way:
percentages_oparea.sort(function(a, b) {
return parseFloat(b.pvalue) - parseFloat(a.pvalue);
});
and it works correctly:
percentages_oparea
0:
name: test2
pvalue: 16
1:
name: test1
pvalue: 15
If b.value
is exactly the same value a.value
I don't want to any sorting. how to achieve this?
I don't know why, but I get this result (test1 and test2 switched indexes) when having exactly the same value in pvalue:
0:
name: test2
pvalue: 15
1:
name: test1
pvalue: 15
But I want (nothing should change)
0:
name: test1
pvalue: 15
1:
name: test2
pvalue: 15