nntrn
2/21/2019 - 2:22 PM

[bubble sort]

[bubble sort]

public static Rentable[] bubbleSort(Object[] arr) {
    Object temp;

    for (int i = 0; i < arr.length - 1; i++) {
        for (int j = 0; j < arr.length - 1; j++) {
          
            double current = arr[j].aGetMethod();
            double next = arr[j + 1].aGetMethod();

            if (current > next) {
                temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }

    return arr;

}