How to sort an associative array by its values in Javascript?
How to sort an associative array by its values in Javascript? I have the associative array: array["sub2"] = 1; array["sub0"] = -1; array["sub1"] = 0; array["sub3"] = 1; array["sub4"] = 0; What is the most elegant way to sort (descending) by its values where the result would be an array with the respective indices in this order: sub2, sub3, sub1, sub4, sub0? Since object properties have no language defined order - you can't (except, perhaps, in some JS engines by depending on the particular way that they implemented properties). – Quentin Mar 4 '11 at 22:23 10 Answers 10 Javascript doesn't have "associative arrays" the way you're thinking of them. Instead, you simply have the abi...