The sorting works fine when the increment operators inner++ and outer++ are in postfix form. However, when I change it to prefix form ++inner and ++outer it no longer sorts. I always thought that it didn't matter which form you used in the third part of a for statement.

Increment and decrement operators when taken as a single statement, behave the same regardless of prefix or postfix. The last segment, as Dave mentioned, of your for loop is considered a single statement as you are currently using it, and as such, the result is the same.

Code:

i++;
++i;

The above two lines have the same result. The difference you'll see is when you do things like: