Computer Science, asked by neenirvik9580, 1 year ago

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

Answers

Answered by fluttershy123VSP
0

hydrogen is the answer

Answered by Oreki
0

A program in Java to demonstrate sorting an Array in Descending order -

import java.util.Arrays;

import java.util.Comparator;

public class Sorting {

public static void main(String[ ] args) {

Integer[ ] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

// Sorting in descending order.

Arrays.sort(array, new Descending( ));

// Printing the sorted array.

System.out.println(Arrays.toString(array));

}

}

class Descending implements Comparator<Integer> {

public int compare(Integer one, Integer two) {

return two.compareTo(one);

}

}

Similar questions