private static void bubbleSort(int[] array) {
    boolean isOrdered;
    for (int i = 0; i < array.length; i++) {
        isOrdered = true;
        for (int j = i + 1; j < array.length; j++) {
            if (array[i] > array[j]) {
                int temp = array[i];
                array[i] = array[j];
                array[j] = temp;
                isOrdered=false;
            }
        }

        if(isOrdered){
            break;
        }
    }
}
Last modification:March 16th, 2021 at 09:26 am