how glDrawElements sort the order of vertex?

I create a grid polygon use the code

 
	wSize = size / w;
	hSize = size / h;

	// create vertices
	//
	//float x=-size/2.0, z=-size/2.0;
	float x=0, z=0;
	for ( int i = 0; i <=h; i++ )
	{
		for ( int j = 0; j <=w; j++ )
		{
			x += wSize;
		}
		//x=-size/2.0;
		x=0;
		z += hSize;
	}

The 2*2 grid should like this:
v6 v7 v8
v3 v4 v5
v0 v1 v2

1*1 grid should be
v2 v3
v0 v1

so, I think the index parameter of glDrawElement() should be
0,1,3,2. but it results a twist squad.
To get a correct squad, I had to input 0,1,2,3…
Is index depend on the order of vertex position creation?
thanks

Twisted quad? Maybe you’re rendering in TRIANGLE_STRIP mode instead of QUAD_STRIP mode…