help sorting an array

any idea how to sort an vector2d array (vector2 List) so that it starts with members (Vector2(x,y)) who have the lowest x?

Check the answers here:

http://answers.unity3d.com/questions/15280/sorting-builtin-arrays

Should be fairly simple to write the comparer to sort by the x value

ok, so for anybody out there, I did it like this:

function bubbleSort(array){
    var continueSort = true;
    if(array.Count >1){
        while (continueSort){
            for(var i=0;i<array.Count;i++)
            {
                for(var j=i+1;j<array.Count;j++)
                {
                    if(array*.x > array[j].x)*
 *{*
 *continueSort = true;*
 _var leftMost=array*;*_
 <em>_array*=array[j];*_</em>
 <em>_*array[j]=leftMost;*_</em>
 <em>_*}*_</em>
 <em>_*else continueSort = false;*_</em>
 <em>_*}*_</em>
 <em>_*}*_</em>
 <em>_*}*_</em>
 <em>_*}*_</em>
<em>_*}*_</em>
<em>_*```*_</em>

Given you use List<>, here's the simplest way(s) I can think of.

// C# Example using lambda
list.Sort((leftMost, rightMost) => leftMost.x - rightMost.x);

// JS/C# Example using delegate
list.Sort(ByVector2X);

ByVector2X must be specified, and here's my version of it:

// C# comparer method
int ByVector2X(Vector2 leftMost, Vector2 rightMost)
{
    return leftMost.x - rightMost.x;
}

// JS comparer method
function ByVector2X(leftMost : Vector2, rightMost : Vector2) : int
{
    return leftMost.x - rightMost.x;
}