How to sort an array of hashmaps in javascript
<p>I have a small question regarding the sorting of a JavaScript array.</p>

<p>I have an array which holds basically a hashmap: 
<code>dataOfTheUserArray=new Array(6);</code>, which is basically an array of hashmaps.
The map looks like the following:</p>

<pre><code>keys:              values

Symbol              xyz
NumberOfStocks      1o
Price               200
</code></pre>

<p>So the array basically contains a map for each symbol.</p>

<p>Now I want to sort the array based on the price of the stock .
So what I did was:</p>

<pre><code>dataOfTheUserArray.sort(sortByPriceBought);

//The call back function is
function sortByPriceBought(a, b) {

    var x = a.Price;
    var y = b.Price;
    return ((x &gt;y) ? -1 : ((x &lt; y) ? 1 : 0));
}
</code></pre>

<p>After sorting it when I iterate through the array the highest price is in the first and all the rest is not sorted.
Is there something I am doing wrong?
I would really appreciate if someone can explain if anything went wrong in the code.</p>
