- "QI ActsAsSorting V0.6"
-key = key || ""

-big_key = qi_ordered_table_name+key.to_s

-@qi_table_orders = @qi_table_orders || {}

-if current_admin

  -if ap = current_admin.admin_preferences.where(:key => "sort_table_"+big_key).first
    -qi_ordered_table_personalised = ap.value


  -if ap = current_admin.admin_preferences.where(:key => "sort_table_"+big_key+"_nbr_col").first
    -qi_ordered_table_nbr_col = ap.value
  -else
    -qi_ordered_table_nbr_col = 1



-else
  -qi_ordered_table_personalised = session[:qi_sort_string][big_key]

  -qi_ordered_table_nbr_col = session[:qi_sort_string][big_key+"_nbr_col"] || 1




-if qi_ordered_table_personalised.to_s != ""
  -@qi_table_orders[big_key.to_sym] = {}

  -qi_ordered_table_personalised.split(",").each do |k|
    -if qi_ordered_table_model.qi_table_order[k.to_sym]
  
      -@qi_table_orders[big_key.to_sym][k.to_sym] = qi_ordered_table_model.qi_table_order[k.to_sym]

-else
  -@qi_table_orders[big_key.to_sym] = qi_ordered_table_model.qi_table_order
