Categories
How to sort an array in C#?
How to sort a one dimensional array in C#? I have a list I would like to sort it in order from largest to smallest. int[] array = new int[]{5, 3, 9, 1, 0, 2}; //Result = 9, 5, 3, 2, 1, 0
int[] array = new int[]{5, 3, 9, 1, 0, 2};
//Result = 9, 5, 3, 2, 1, 0
Answer the question
In order to leave comments, you need to log in
var res = array.OrderByDescending(x=>x);
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question