Do Transform[] lose all the typical array methods such as sort()?

I have this private var which represents an array of barrels on my platform that this script is attached to.

private var BarrelsThisPlatform : Transform[] = new Transform[12];

On my scripts Start() I populate this array with my barrels:

  	var i=0;
  	for (var child : Transform in transform) {
    	if (child.name == "Barrel"){
			BarrelsThisPlatform[i] = child;
			i++;
    	}
	}

Then in another method I want to blow up a random number of these barrels. My thought process is to:

  1. Randomly sort the barrels
  2. Splice the first X elements of my transform array into a new array.
  3. Loop across this new array and call ‘BlowUp’ on these barrels.

The problem I’m running into is that the Transform[ ] doesn’t have all the methods that a normal array has seen here. OR, maybe it doesn’t and I’m not calling it correctly. Can anyone assist me with this?

Here’s my code:

function openBarrels(){
	var numOfBarrels: int = BarrelsThisPlatform.Length -1;
	var barrelsDestroyed: int = 0;
	
	while(barrelsDestroyed <= barrelsToDestroy){
		var myRandom: int = Random.Range(0,numOfBarrels);
		
		var other : BarrelBehaviors = BarrelsThisPlatform[myRandom].gameObject.GetComponent(typeof(BarrelBehaviors));
		other.BlowUp();
		barrelsDestroyed++;
	}
}

UnityEngine.Array is not the same thing as System.Array.

http://msdn.microsoft.com/en-us/library/system.array(v=vs.90).aspx

That’s not a “normal array”, that’s the JS Array class, which should not be used anyway (slow, untyped, limited, obsolete). Always use built-in arrays or generic Lists. See the MSDN docs, such as the page KelsoMRK linked to, for documentation on arrays and Lists. You’ll need to make a function that specifies how to sort Transforms (since Unity hasn’t any idea what criteria you want to use for the sort), which you can use with System.Array.Sort or List.Sort.

–Eric