javascript getting index of nested function within function
<p>I have a function that sorts an array and within it, I have custom sort functions. Something like this:</p>

<pre><code>function SortTheArray() {

  function SortCriteria1Asc(a, b) { ... }
  function SortCriteria1Dsc(a, b) { ... }
  function SortCriteria2Asc(a, b) { ... }
  function SortCriteria1Asc(a, b) { ... }

  var CustomSort;

  switch (SomeVar) {

     case 1:
       CustomSort = SortCriteria1Asc;
       break;

     case 2:
        CustomSort = SortCriteria1Dsc;
        break;

     case ....
  }

  SomeDataArray.sort(CustomSort);
}
</code></pre>

<p>Is it possible to remove the <code>switch</code> statement and say that the <code>CustomSort</code> function is simply equal to the nth nested function?</p>

<p>Thanks for your suggestions. </p>
