The result of an assignment is the left operand, so the condition
sorted = !sorted
is using sorted
as the condition after it's assigned a new value. The warning is there to give you a notice that using assignment as condition is sometimes not what you expected. You can use
(sorted = !sorted) == true
to silence the warning.