Newbie in need of help

hey, i hope i’ll be able to explain myself properly:

i have 9 images, when one of them is clicked i need it to move on the x line to a certain point. when another image is pressed i want the previous image to go to where the new one was and the new one to go to the point on the x line where the chosen image is displayed.

how do i keep up after the images locations so that i know where the old image should go?