Thanks Oscar, In my case this did the trick. sortedVal=np.array(val[ind]).reshape((xcoord.size,ycoord.size,zcoord.size))