Array.ToBuiltin() problem

I made the following static function to sort a builtin array:

static function ArraySort( arr : int[] ) : int[] {
   var newarr : Array = new Array(arr);
   newarr.Sort();
   arr = newarr.ToBuiltin(int);
   return arr;
}

But I get this error?

BCE0022: Cannot convert 'System.Array' to 'int[]'.

It's an issue with using #pragma strict without #pragma downcast. Add the latter in and it'll be able to downcast it to the correct type.

You can also use the .NET built in sort too:

static function ArraySort( arr : int[] ) : int[] {
    System.Array.Sort(arr);
    //alternatively, duplicate the array first, then returned the sorted copy
}

http://msdn.microsoft.com/en-us/library/kwx6zbd4.aspx