fixed sort in query