javascript custom sort when parts of an array has no data
<p>I have an object model that looks like this:</p>

<pre><code>MyObject = {
   TheName: "",
   OtherProps :....
}
</code></pre>

<p>I have an array of these objects and my custom sort function looks like this:</p>

<pre><code>function SortArray() {

  var CustomFunction;

  var CustomSortAsc = function (a, b) {
    return a['TheName'] - b['TheName'];
  }

  var CustomSortDsc = function (a, b) {
    return b['TheName'] - a['TheName'];
  }

  if (SomeCondition) {
      CustomFunction = CustomSortAsc;
  } else {
      CustomFunction = CustomSortDsc;
  }

  SomeArray.sort(CustomFunction);
}
</code></pre>

<p><code>SomeArray</code> has somewhere around 200-300 objects in it and the problem is that sometimes the object has an empty <code>TheName</code> property. Because of that, the sort doesn't seem to work as expected. For instance, if there are values then sort by name and then put all the values for which there are no names according to the sort function.</p>

<p>What's the way to make this work? Thanks for your suggestions.</p>
