Skip to content

Latest commit

 

History

History
22 lines (22 loc) · 603 Bytes

Q3.md

File metadata and controls

22 lines (22 loc) · 603 Bytes
public static void DescSort(Integer[] a) {
    if (a != null) {
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a.length - 1; j++) {
                if (a[j] <= a[j + 1]) {
                    int temp = 0;
                    temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
        System.out.print("Array after DescSort: ");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
      }
    } else {
    System.out.println("Null array.");
    }
}