I'm new to programming and just trying to wrap my head around lists and clone data.
My task is to gather x-position data from all clones created (user integer input creates number of clones) and find the 2 closest clones relative to their x-position, and present that information in a list. The y-position of all clones is locked and irrelevant.
I am struggling with comparing all the x-position data to find the closest pair.
So, instead of making the n² comparisons of every position to every other position, I would sort the clones by x position, and then you can just compare the differences between adjacent ones. (That wouldn't work if you were comparing distances in two dimensions, but you're not.)
Is this a homework problem? The otherwise strange irrelevance of the y position sounds like a teacher trying to make the problem easy for you. I ask because I don't know what the rules are, e.g., whether I can point you to the library procedure that sorts lists.