errors in sorting