update sorting controller code for rails 4.1