Skip to content

Latest commit

 

History

History
22 lines (22 loc) · 608 Bytes

Q2.md

File metadata and controls

22 lines (22 loc) · 608 Bytes
public static void EscSort(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 EscSort: ");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        } 
    } else {
        System.out.println("Null array.");
    }
}