I have an associative array with keys as strings. Now I want to sort them by value descending.
This is the expected result:
[orange: 3, apple: 2,  banana: 1]
But with:
    var arr = [];
    arr["apple"] = 2;
    arr["orange"] = 3;
    arr["banana"] = 1;
    arr.sort(function(a,b) {
        return a.val - b.val;
    });
I get the initial order:
[apple: 2, orange: 3, banana: 1]
 
     
    