Sorting help

Hey, so i’ve got a movie clip, and 4 points around it, and what i’m trying to do is to make the movie clip move towards the closest target. I’m slightly stuck at the moment. I can make my movie clip move to any specific point, and I can find the distance between my movie clip and any point, but i’m having trouble sorting the different points based on their distance from my movie clip. Heres what i’ve got at the moment.

point1={x:20,y:20};
point2={x:530,y:20};
point3={x:20,y:380};
point4={x:530,y:380};

pointA = [point1, point2, point3, point4];
ballA = [];

for(i=0; i<5; i++)
{
        ball = attachMovie("ball", "ball"+_root.getNextHighestDepth(), _root.getNextHighestDepth())
        ball._x = Math.random()*450+50;
        ball._y = Math.random()*300+50;
        ballA.push(ball);
                
        _root.onEnterFrame = function() {
            move(pointA[1]);
        }
}

function move(target)
{
    for (i=0; i < ballA.length; i++) {
        if (target.x < ballA*._x)
            ballA*._x -= 2;
        if (target.x > ballA*._x)
            ballA*._x += 2;
        if (target.y < ballA*._y)
            ballA*._y -= 2;
        if (target.y > ballA*._y)
            ballA*._y += 2;
    }
}

I’m checking the distance between my ball and the target with this…

Math.sqrt((ball._x-pointA[0].x)^2+(ball._y-pointA[0].y)^2);

Any help would be appreciated.