Corrected sort check