Hi, I’m trying to make a ranking with the best scores. All scores are stored in an array, but when I try to sort the values to make a ranking, Unity returns the following message:
Assets/Scripts/Test.cs(12,29): error CS1501: No overload for method Sort' takes
0’ arguments
and
Assets/Scripts/Test.cs(12,27): error CS0103: The name `Array’ does not exist in the current context
I looked for answers in Unity Answers, Unify Community, MSDN Library, but still doesn’t work. Is possible sort values in Unity/C#?
My Code:
public int[] playerScore = new int [] {35, 53, 32, 27, 16, 72, 44, 83, 51, 91};
// Use this for initialization
void Start () {
playerScore.Sort();
}
and another try:
public int[] playerScore = new int [] {35, 53, 32, 27, 16, 72, 44, 83, 51, 91};
public int[] ranking;
// Use this for initialization
void Start () {
ranking = Array.Sort ( playerScore );
}
Thanks guys!!