add freq and sort docID