title: Sorting AngularJS smart-table bound to list of IDs
body: <p>I have an AngularJS controller that retrieves several collections of IDs (ordered and filtered differently) and a dictionary mapping IDs to the actual data.</p>
  
  <p>I am trying to use smart-table to display the data and allow the user to sort and filter it. I am having troubles with how to handle a level of indirection from key to the actual data with smart-table. </p>
  
  <p>A solution found in a sample code for st-sort is to use a getter function, but it seems to be too verbose as I will need to define a getter function for each field individually. Also, I didn't get what I should put in st-sort when the array contains scalars and not objects with attributes.</p>
  
  <p>Also, I am not sure if there won't be troubles with other parts of smart-table because of this indirection like with filtering.</p>
  
  <p>I would appreciate any advice on the best way to approach it.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code> angular.module('myApp', ['smart-table'])
      .controller('mainCtrl', ['$scope',
          function ($scope) {
  
            $scope.ordered_ids = [ 'id-1', 'id-2', 'id-3' ];
  
            $scope.data = {
                'id-1': {firstName: 'Laurent', lastName: 'Renard', birthDate: new Date('1987-05-21'), balance: 102, email: 'whatever@gmail.com'},
                'id-2': {firstName: 'Blandine', lastName: 'Faivre', birthDate: new Date('1987-04-25'), balance: -2323.22, email: 'oufblandou@gmail.com'},
                'id-3': {firstName: 'Francoise', lastName: 'Frere', birthDate: new Date('1955-08-27'), balance: 42343, email: 'raymondef@gmail.com'}
            };
  
            $scope.getter=function (value) {
                return $scope.data[value];
            }         
  
          }
      ]);
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table st-table="ordered_ids" class="table table-striped"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th st-sort=""&gt;ID&lt;/th&gt;
            &lt;th st-sort="getter"&gt;First name&lt;/th&gt;
            &lt;th&gt;Last name&lt;/th&gt;
          &lt;th&gt;Email&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;tr ng-repeat="id in ordered_ids" ng-init="e = data[id]"&gt;
        &lt;td&gt;{{id}}&lt;/td&gt;
          &lt;td&gt;{{e.firstName}}&lt;/td&gt;
          &lt;td&gt;{{e.lastName}}&lt;/td&gt;
          &lt;td&gt;{{e.email}}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><a href="http://plnkr.co/edit/m9317hIDmnfx1mJDCJVN?p=preview" rel="nofollow">Plunker</a></p>