fixed document sorting