edit algorithm/Sorting