added test when the sort function fails