In the first attempt, you locked the first created sprite to the mouse. Then you looped trough all sprites, and feeded all those to the function.
The function is a NEW TOP-EVENT, so it forgets (by design, and luckely so) any previous picked lists. So the function picks out of all sprites those that that have a differend UID then those you feeded to the function. And yes, including the one you locked to the mouse. But also all others. Then loops trough them, and compares the distance. As a result they kinda flip-flop. In one loop one gets set 50 % opaque, in the next loop that same one gets back to 100 %. You needed to compare to only that one that you locked to the mouse.
In the second attempt. The for each runs on each member of the family, because there is no previous picked list. There is also no previous picked list for Sprite. So it picks out of all sprites those that dont have the same UID. Wich is just all of them. So basecaly it runs trought all family members and for each famely member it runs trough all sprites. If you have 100 sprites, that would be a loop that counts 100 * 100 times. Again creating some flip-flop thing.
Here is a working example. I used drag and drop to be able to explore more situations.
https://drive.google.com/open?id=0B1SSu ... HUydDNQcmM
As you see i feed to the function only the postion of ONE sprite. In the function i pick all but that one sprite. Then i compare the distance of those only one time against the position of that one sprite.