Correction of an error in sorting