I
I
Ilya2021-05-01 13:34:17
Arrays
Ilya, 2021-05-01 13:34:17

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2021-05-01
@stead

var res = array.OrderByDescending(x=>x);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question