Maybe the answer is that, before calling gridFactory.createGrid() the boundary segment indices are not defined therefore is impossible to reorder. Am I right?