How can you sort the elements of the array in descending order? if yes then how?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Posted Jun 7, 2011, 8:14 PM EDT
First sort the array and do reverse.
int[] intArray = new int[5] { 8, 10, 2, 6, 3 };
Array.Sort(intArray);
Array.Reverse(intArray);
foreach (int i in intArray)
Console.Write(i + " "); // output: 10 8 6 3 2