3
Reply

How can you sort the elements of the array in descending order?

Pradeep

Pradeep

15y
5.8k
0
Reply

    Hello Pradeep

     The answers suggeted by other users should work fine. There are better means of sorting arrays, depending upon the type of data that they carry. Some of the techiniques are Bubble Sort, Liner Sort, Selection Sort each of these will solve your problem, all you have to do modify the logoc appropriately. 

     For Ex.

      A simple Linear Sort  will swap the location of the elements if  (arr[i]>arr[i+1]), then swap , just  change that to if(arr[i+1>arr[i]) , then swap

    By calling Sort() method and then Reverse() method.

    use sort and reverse methods of array

    array.sort() - this sorts in asc order

    array.reverse()