sorting by qid