Sorting Associative Array in Javascript
<p>I am new to this board have been fishing for info here for a long time and this is my first time posting here. I am in sort of a jam right now I have an array in javascript that looks like this. Each ID is accociated with a persons name</p>

<pre><code>        Array
         (
            [230] =&gt; Smith, Marc-Andre 
            [11369] =&gt; Smith, Wayne 
            [12561] =&gt; Smith, Diane 
            [12637] =&gt; Smirnova, Natalie
         )
</code></pre>

<p>Right now the array is sorted by the index which is the ID of the person. I am wondering if its possible to sort it alphabetically such that the array now looks like </p>

<pre><code>          Array
          (
             [12637] =&gt; Smirnova, Natalia 
             [12561] =&gt; Smith, Diane 
             [230] =&gt; Smith, Marc-Andre 
             [11369] =&gt; Smith, Wayne       
          )
</code></pre>

<p>So far I tried using array.sort() it does sort alphabetically but the ID is lost it gives me </p>

<pre><code>      Array
          (
             [0] =&gt; Smirnova, Natalia 
             [1] =&gt; Smith, Diane 
             [2] =&gt; Smith, Marc-Andre 
             [3] =&gt; Smith, Wayne       
          )
</code></pre>

<p>This is my first time programming javascript so thanks for all the help in advance. </p>
