title: yii2 sort gridview on function column
body: <p>I have a grid view i am populating with a data provider that gets its data from an active query. One of my columns is displayed via a function in the view that evaluates data from 2 different tables and displays one or the other value (based on date) i would like to be able to sort this column, but because its not part of the original SQL statement the ORDER BY clause created by the sort widget is not aware of the column to sort on. My question is, is there a way to sort the data after it has been passed and loaded into the grid view, or is there a better way to gather the data retrieved from the function so that it can be sorted. </p>
  
  <pre><code>[
    'label'=&gt;'Last Backup Date',
    'value'=&gt;function($data)
  {
    if(!is_null($data-&gt;backupEvent) &amp;&amp; !is_null($data-&gt;backups))
  {
    return MAX($data-&gt;backupEvent-&gt;eventTime,$data-&gt;backups-&gt;fieldValue);
  }elseif(!is_null($data-&gt;backupEvent))
  {
    return $data-&gt;backupEvent-&gt;eventTime;
  }elseif(!is_null($data-&gt;backups)) {
    return $data-&gt;backups-&gt;fieldValue;
    }
   }
  ],
  </code></pre>