How to swap images and their table index.

I create a table myTable to hold some images .(attached file question_01.jpg)

After using “transition.to” method, I swap two images. It just swap the position, not their table index.

(attached file question_02.jpg)

I need the myTable[1][1] become the blue rectangle, and the myTable[1][2] become the red rectangle.

Don’t know how to do that, somebody help !!

Thank you.

Something like this?

local swapObject = function(obj1, obj2) return obj2, obj1; end -- usage: myTable[1][1], myTable[1][2] = swapObject(myTable[1][1], myTable[1][2]);

It’s working !! Thank you so much!!

Something like this?

local swapObject = function(obj1, obj2) return obj2, obj1; end -- usage: myTable[1][1], myTable[1][2] = swapObject(myTable[1][1], myTable[1][2]);

It’s working !! Thank you so much!!