Further improve sort error handling.

Change-Id: Ib5b75f36bf729110d603d61fbd60c1fbefe81818
Reviewed-By: svevan01