Correct advanced sort of the SearchDoc (closes #5066, closes #5065)