added sorting to get all queries