public static IntArray sortBidirectional(IntArray array){

		System.out.print("Original array: ");
		array.print();
		
		// n is the index of the last value in the array
		int n = array.size() - 1;
		
		boolean reverse = false;
		int outerFwd = n;
		int outerBwd = 0;
		
		// Main loop
		while(outerFwd != outerBwd){
			
			if(!reverse){
				for(int inner = 0; inner < outerFwd; inner++){
					if(array.get(inner) > array.get(inner + 1)){
						array = swap(array, inner, inner + 1);
					}
				}
				
				System.out.print("Current pass: ");
				array.print();
				
				outerFwd--;
				reverse = true;
			} else {
				for(int inner = n; inner > outerBwd; inner--){
					if(array.get(inner) < array.get(inner - 1)){
						array = swap(array, inner, inner - 1);
					}
				}
				
				System.out.print("Current pass: ");
				array.print();
				
				outerBwd++;
				reverse = false;
			}
		}

		System.out.print("Sorted array: ");
		array.print();
		return array;
	}