0

What on earth does Array.Sort() do?

On the C# lesson where we learn about static classes, it has an array ( int arr[] = {9, 4, 10, 42}; ), and it asked what the first element would be if you used Array.Sort(). Why is the answer 3?

21st Jun 2020, 2:57 PM
ANNA TOWNSEND
ANNA TOWNSEND - avatar
1 Answer
+ 8
ANNA TOWNSEND Array.Sort() is use to sort the array elements is ascending order . Sort() contains 1 parameter so we can sort array like this Array.Sort(arr); //after using this, array will be {4, 9, 10, 42) first element will be 4 Because It's smallest value of array. This is Incomplete question. This https://www.sololearn.com/post/445402/?ref=app was your problem. Answer is 3 because we are taking the square root of 2nd element using sqrt() method after sorting which is at 1 index.
21st Jun 2020, 3:06 PM
A͢J
A͢J - avatar