Hey guys i have this code copied exactly the same (ive already check like 10 websites) code but for some reason I keep getting an error.
MissingMethodException: Method not found: ‘System.Int32[ ].sort’.
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
var fruits = ["Banana", "Orange", "Apple", "Mango"];
function Start()
{
fruits.sort();
//print("" + fruits);
}
why doesnt this work???
The Sort function has a capital S.
hmm thanks for the reply I changed it to a capital S and now I get this
Assets/bottomGUI.js(33,20): BCE0023: No appropriate version of ‘System.Array.Sort’ for the argument list ‘()’ was found.
also all the other code examples use a lower case S
some references
http://solutoire.com/2007/05/02/sorting-javascript-arrays/
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Well I’m not too sure how the Array is suppose to be like for Unityscript but it sure looks different from the example in the documentation.
http://docs.unity3d.com/Documentation/ScriptReference/Array.Sort.html
oh wow thanks that worked, i should have just used the scripting reference cheers mate.
The Unity docs for Array don’t apply here. What you’re using is a built-in string array, not Array (which is good, because there’s no reason to use Array…use built-in arrays if the size doesn’t need to change, or List if it does). The correct docs are here: Array Class (System) | Microsoft Learn
–Eric