sort error handling