title: Implementing sort ASC or DESC in Rails
body: <p>I am working with an open source school management software, Fedena and I am trying to sort a list of users by their surnames. The software currently shows all users with their first names. I've found these two files to be responsible for showing the information I intend to change.</p>
  
  <p><strong>student_controller.rb</strong></p>
  
  <pre><code>def list_students_by_course
  @students = Student.find_all_by_batch_id(params[:batch_id], :order =&gt; 'last_name ASC')
  render(:update) { |page| page.replace_html 'students', :partial =&gt; 'students_by_course' }
  end
  </code></pre>
  
  <p>When I delete the above section of the file, the users names don't show up so I believe this section to be responsible for populating the table with the usernames. </p>
  
  <p><strong>_students_by_course.erb</strong></p>
  
  <pre><code>&lt;div class="students-table"&gt;
    &lt;table align="center" width="100%" cellpadding="1" cellspacing="1"&gt;
      &lt;tr class="tr-head"&gt;
        &lt;td&gt;&lt;%= t('sl_no') %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= t('name') %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= t('adm_no') %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;% @students.each_with_index do |r, i| %&gt;
        &lt;tr class="tr-&lt;%= cycle('odd', 'even') %&gt;"&gt;
          &lt;td class="col-1"&gt;
            &lt;%= i+1 %&gt;
          &lt;/td&gt;
  
          &lt;td class="col-2"&gt;
            &lt;%= link_to r.full_name,:controller =&gt; "student", :action =&gt; "profile", :id =&gt; r.id %&gt;
          &lt;/td&gt;
  
          &lt;td class="col-1"&gt;
            &lt;%= r.admission_no %&gt;
          &lt;/td&gt;
  
          &lt;td class="col-7"&gt;
            &lt;%=  link_to  "#{t('view_profile')}", :controller =&gt; "student", :action =&gt; "profile", :id =&gt; r.id %&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have tried changing 'last_name ASC' to 'last_name DESC' but nothing changed. 
  Any help is appreciated.</p>