gridfill error : Connecting edge loops overlap
I'm not sure why it doesn't work the way you are trying, I would venture to guess it's a bug or a limitation of the algorithm, as there is no reason for it to work one way and not the other. 

That said, you can still use the grid fill tool on the empty section if you select the two 'connecting' edges (the horizontal ones in the image above). You can also go into the settings of the failed gridfill and change the span to 6 and the offset to 1 and that works too.

Also, if you add geometry around all the edges it will work as well.