def sort(field, options = {}, html_options = {})
      unless options[:as]
        id           = field.to_s.downcase == "id"
        options[:as] = id ? field.to_s.upcase : field.to_s.humanize
      end

      ascend  = "#{field}|ASC"
      descend = "#{field}|DESC"

      ascending = params[:order] == ascend
      new_sort = ascending ? descend : ascend
      selected = [ascend, descend].include?(params[:order])

      if selected
        css_classes = html_options[:class] ? html_options[:class].split(" ") : []
        if ascending
          options[:as] = "&#9650;&nbsp;#{options[:as]}"
          css_classes << "ascending"
        else
          options[:as] = "&#9660;&nbsp;#{options[:as]}"
          css_classes << "descending"
        end
        html_options[:class] = css_classes.join(" ")
      end

      url_options = params.merge(:order => new_sort)

      options[:as] = raw(options[:as]) if defined?(RailsXss)

      a_link(options[:as], html_escape(url_for(url_options)), html_options)
    end
def sort(field, options = {}, html_options = {})
      unless options[:as]
        id           = field.to_s.downcase == "id"
        options[:as] = id ? field.to_s.upcase : field.to_s.humanize
      end

      ascend  = "#{field}|ASC"
      descend = "#{field}|DESC"

      ascending = params[:order] == ascend
      new_sort = ascending ? descend : ascend
      selected = [ascend, descend].include?(params[:order])

      if selected
        css_classes = html_options[:class] ? html_options[:class].split(" ") : []
        if ascending
          options[:as] = "&#9650;&nbsp;#{options[:as]}"
          css_classes << "ascending"
        else
          options[:as] = "&#9660;&nbsp;#{options[:as]}"
          css_classes << "descending"
        end
        html_options[:class] = css_classes.join(" ")
      end

      url_options = params.merge(:order => new_sort)

      options[:as] = raw(options[:as]) if defined?(RailsXss)

      a_link(options[:as], html_escape(url_for(url_options)), html_options)
    end
These 2 methods copied from scoped_search {https://github.com/wvanbergen/scoped_search}
 which Katello used to use but no longer uses.

 Creates a link that alternates between ascending and descending.

 @example
   sort @search, :by => :login
   sort @search, :by => :created_at, :as => "Created"

 @param [Hash] options This helper accepts the following options:
 @option options [String] :by the name of the named scope. This helper will prepend this value with "ascend_by_" and "descend_by_"
 @option options [String] :as the text used in the link, defaults to whatever is passed to :by