title: Sort on underlying data in ng-grid
body: <p>I wish to display a formatted value in a ng-grid cell, but sort on a related numeric value not displayed.</p>
  
  <pre><code>var myData1 = [{
   name: "Moroni",
    age: 50,
    ageWord: "Fifty"
  }
  </code></pre>
  
  <p>From the above example I would display the ageWord column, but wish to sort on the age column.</p>
  
  <p>The <a href="http://angular-ui.github.io/ng-grid/">docs</a> for sorting an ng-grid directive indicate I can provide a custom function to sort underlying data:</p>
  
  <p><strong>sortFn</strong></p>
  
  <blockquote>
    <p>Sets the sort function for the column. Useful when you have data that is formatted in an unusual way or if you want to <strong>sort on an underlying data type</strong>. Check the MDN sort docs for examples</p>
  </blockquote>
  
  <p>the custom sort function receives the display values when the column sort is clicked, but I wish to sort on the age.  If I had the row available in the sort function I could sort on the sibling cell, something like this:</p>
  
  <pre><code>sortFn: function(a, b) {
      var ageA = a.getProperty('age');
      var ageB = b.getProperty('age');
      return ageA-ageB;
    }
  </code></pre>
  
  <p>Any suggestions how I can sort by 'age' when the 'ageWord' column is sorted?  Example available <a href="http://plnkr.co/edit/4PRYP53z99JIwD1s2dU9?p=preview">on plnkr</a>. </p>