Add sorting option for query