Added assertion to sort