fixed sorting of documents