Order Waypoints

hi!

im using this script in java:

var wayPoints : GameObject[];

function Start ()
{
   wayPoints = GameObject.FindGameObjectsWithTag("WayPoints");
}

my waypoints have the names target 1, target 2, target 3, target 4, … and so on. what i want now is that it orders the waypoints in the array in the order the targets number is.
so on the place 0 in the array should target 1 be, on the place 1 the target 2 and so on. could anybody please help me writig the script right?
thank you very much!!

You have to do it like this:

var wayPoints : List.<GameObject>;

function Start ()
{
    wayPoints = new List.<GameObject>(GameObject.FindGameObjectsWithTag("WayPoints"));
    wayPoints.Sort(function(O1 : GameObject,O2 : GameObject):int { return O1.name.CompareTo(O2.name);});
}