Added check for second sort option.