changed sort to doc_element