title: Angular OrderBy by object property in sub array
body: <p>I have a table...</p>
  
  <pre><code>&lt;table width="100%"&gt;
          &lt;thead&gt;
              &lt;tr ng-repeat="row in data.Rows | limitTo:1"&gt;
                  &lt;th ng-repeat="col in row.Columns" ng-show="{{col.Visible}}" ng-click="updateSortOrder(col.HeaderText)"&gt;
                      &lt;a href&gt;{{ col.HeaderText }}&lt;/a&gt;
                  &lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr ng-repeat="row in data.Rows | orderBy: ??? "&gt;
                  &lt;td ng-repeat="col in row.Columns" ng-show="{{col.Visible}}"&gt;
                      {{ col.Value }}
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>and I have a JSON file with the following data structure...</p>
  
  <pre><code>"Rows": [{
           "Columns": [{
               "HeaderText": "Policy Number",
               "Value": "A123456789",
               "Visible": true
           }, {
               "HeaderText": "VRM",
               "Value": "XX12XXX",
               "Visible": true
           }, {
               "HeaderText": "Event Date",
               "Value": "2014-12-08 08:39:38.000",
               "Visible": true
           }, {
               "HeaderText": "Road SL",
               "Value": 30,
               "Visible": true
           }, {
               "HeaderText": "Speed",
               "Value": 39,
               "Visible": true
           }]
       }
  </code></pre>
  
  <p>I would like to be able to sort the data in the table by the corresponding "Value" property when the "HeaderText" is clicked. So if the user clicked on "Policy Number" header on the table, the table will sort by the Column object with "Policy Number" in it's "HeaderText" property by the objects "Value" property. (hope that makes sense!?)</p>
  
  <p>How can i go about doing this? I'm new to Angular, so please be gentle :)</p>
  
  <p>EDIT::
  Following the advice given in the first answer and it's not quite working.</p>
  
  <p>My updated code as follows...</p>
  
  <pre><code>&lt;div ng-controller="ReportsController"&gt;
  &lt;h1&gt;{{ data.ReportTitle }}&lt;small ng-show="predicate !== null"&gt;Ordered by: {{data.Rows[0].Columns[predicate].HeaderText }} {{reverse ? "desc" : "asc"}}&lt;/small&gt;&lt;/h1&gt;
  &lt;div&gt;{{ error }}&lt;/div&gt;
  &lt;table width="100%"&gt;
      &lt;thead&gt;
          &lt;tr ng-repeat="row in data.Rows | limitTo:1"&gt;
              &lt;th ng-repeat="col in row.Columns" ng-show="{{col.Visible}}" ng-click="updateSortOrder($index)"&gt;
                  &lt;a href&gt;{{ col.HeaderText }}&lt;/a&gt;
              &lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr ng-repeat="row in data.Rows | orderBy:[predicate]:reverse "&gt;
              &lt;td ng-repeat="col in row.Columns" ng-show="{{col.Visible}}"&gt;
                  {{ col.Value }}
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <p>and my controller...</p>
  
  <pre><code>var ReportsController = function ($scope, $http, $routeParams) {
  
      $scope.data = {};
  
      var onDataRetreived = function (response) {
          $scope.data = response.data;
      }
  
      var onError = function (reason) {
          controller.error = "Could not fetch data.";
      }
  
      $http({
              method: 'GET',
              url: 'data/report.json'
          })
          .then(onDataRetreived, onError);
  
      $scope.predicate = 0;
      $scope.reverse = true;
      $scope.updateSortOrder = function (predicate) {
          $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;
          $scope.predicate = predicate;
      };        
  };
  
  angular.module('Portal').controller('ReportsController', ['$scope', '$http', '$routeParams', ReportsController]);
  </code></pre>
  
  <p>The sorting apears to change, but it's not sorting on the Value of column that i click on. Any ideas?</p>