title: Rails a simple way to sort a list of users in reversed alphabetical order
body: <p>I have this line of code in my rails 4 application,</p>
  
  <pre><code>= link_to t('first_name'), url_for(sort: "users.first_name"), style: 'color: white'
  </code></pre>
  
  <p>it sorts my table of users first names alphabetically on the first click. I've been trying to find a way to make it sort first names in reversed alphabetical order on the second click following this format but to no avail any suggestions?</p>
  
  <p>The controller responsible for this according to my log is</p>
  
  <pre><code>def set_memberships
          @memberships = current_organization.memberships
            .includes(:roles, :user, linked_membership: :organization)
          if params[:action] == 'retired_memberships'
            @memberships = @memberships
              .joins("INNER JOIN users on users.id = memberships.user_id")
              .joins("LEFT OUTER JOIN memberships as linked_memberships ON memberships.linked_membership_id = linked_memberships.id")
              .where("(memberships.linked_membership_id is NOT NULL AND memberships.retired = true AND linked_memberships.retired = false) OR 
                (memberships.retired = true AND memberships.linked_membership_id IS NULL)")
              .where(retired: true)
          else
            @memberships = @memberships
              .joins("INNER JOIN users on users.id = memberships.user_id")
              .joins("LEFT OUTER JOIN memberships as linked_memberships ON memberships.linked_membership_id = linked_memberships.id")
              .where("(memberships.linked_membership_id IS NUll AND memberships.retired = false) OR 
                (memberships.linked_membership_id is NOT NULL AND memberships.retired = false AND linked_memberships.retired = true)")
          end
          @sort_field = params[:sort].presence || "users.last_name"
          @memberships = @memberships.order(@sort_field).page(params[:page]).per(30)
        end
  </code></pre>
  
  <p>Probably worth noting that this controller sorts by more then just first names but I'm asking for first names to keep it simple. </p>