fixed prostgres order by issue