title: Active Admin: How to add a custom sortable column?
body: <p>I'm trying to add a column to an index table, where the column's data is created dynamically when the table is loaded, and is not stored in a database.</p>
  <p>With the following code I was able to create the column, but I can't seem to figure out how to sort it based on the dynamically created data the column will store.</p>
  <pre><code>index do
      selectable_column
      id_column
      column :name
      column :email
      column :role
      column :company
      column :sign_in_count
      column :created_at
      column :updated_at
      if current_scope.id == 'therapists'
         column :average_rating, sortable: true do |user|
             avg = Ticket.where(format('therapist_id = %d', user.id)).average(:client_rating)
             if avg.nil?
                'No Rating'
             else
                format('%.2f', avg)
            end
         end
       end
  
  actions
  end
  </code></pre>
  <p>As is, the code fails because it tries to handle the sorting by pulling from a column called &quot;average_rating&quot; which doesn't exist. I've tried overriding the <code>order_by(:average_rating) do |order_clause|</code> and <code>def scoped_collection</code> but I couldn't get either to work.</p>
  <p>All I need is some simple way to sort the values in the cell without trying to sort with a database query.</p>