JavaScript datastructure for easy multidimensional sorting
<p>I have the following <strong>information</strong>: </p>

<pre><code>Name, GPA 2010, GPA 2011
Adam, [2010, 3.4], [2011, 3.9]
Ben, [2010, 3.4], [2011, 3.9]
Charlie, [2010, 3.4], [2011, 3.9]
</code></pre>

<p>I'd like to be able to do the following:</p>

<ol>
<li>Sort alphabetically by name</li>
<li>Sort by the GPA achieved in 2010</li>
<li>Sort by the GPA achieved in 2011</li>
<li>Add new users to the list iff their name isn't already on it. </li>
</ol>

<p>What is the most economical JavaScript data structure to use for this sort of sorting?</p>

<p>Currently I have this: </p>

<pre><code>var grades = { 
'Adam':  [[2010, 3.4], [2011, 3.9]],
'Ben' :  [[2010, 3.4], [2011, 3.9]],
'Charlie' : [[2010, 3.4], [2011, 3.9]] };
</code></pre>

<p>This makes it easy to achieve point 4 (<code>if (name in grades === false)</code>) and <a href="http://stackoverflow.com/questions/890807/iterate-over-a-javascript-associative-array-in-sorted-order">reasonably easy</a> to achieve point 1, but quite fiddly to achieve point 2 or 3. </p>
