If you physically reorder the rows in the XML then you don't have to maintain anything.
Check out the InfoPathDev Example titled, "Reordering Table Rows"

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hi
I have got a repeated table... now enduser enters some rows at run time.
Each row added also has two buttons ( UP and DOWN ). Say end user adds 4
rows . If he presses UP button of the 4th row the contents of the fourth
row shud get replaced by 3rd and contents of 3rd row with 4th row.
I suppose I'll have to maintain certain indexing... but i'm unable to index
rows in repeated table to uniquly identify them in scripting..