added sort order for activerecord queries