I have an array and when I console.log it it give me this:
[paris: 348589.40826358093, londres: 490078.8871883664, nantes: 6363.461319105993]
I want to sort the array by the value (the number), be I can't figure how to do it. i want a result order by the value like this: [nantes: 6363.461319105993, paris: 348589.40826358093, londres: 490078.8871883664] I have try with something like this but it's not working.
function compare(x, y) {
return x - y;
}
tab.sort(compare);