Quick Sort

Implementation of Quick Sort

QuickSort.java
public class QuickSort { 
 
    public static void main(String[] args) { 
 
        int[] input; 
        int length; 
 
        String inputString = "4143675351981074"; 
        length = inputString.length(); 
 
        input = new int[length]; 
        for (int i = 0; i < length; i++) { 
            input[i] = Character.getNumericValue(inputString.charAt(i)); 
        } 
 
        System.out.println("Unsorted list:"); 
        printList(input); 
        System.out.println(); 
 
        input = quickSort(input); 
        System.out.println(); 
 
        System.out.println("Sorted list:"); 
        printList(input); 
 
    } 
 
    public static int[] quickSort(int[] list) { 
        sort(list, 0, list.length - 1); 
        return list; 
    } 
 
    public static void sort(int[] list, int leftBound, int rightBound) { 
        if (leftBound >= rightBound) { 
            return; 
        } 
 
        int pivot = list[leftBound + (rightBound - leftBound) / 2]; 
 
        int i = leftBound; 
        int j = rightBound; 
 
        while (i <= j) { 
            while (list[i] < pivot) { 
                i++; 
            } 
            while (list[j] > pivot) { 
                j--; 
            } 
            if (i <= j) { 
                swap(list, i, j); 
                i++; 
                j--; 
            } 
            printList(list); 
        } 
 
        if (leftBound < j) { 
            sort(list, leftBound, j); 
        } 
        if (rightBound > i) { 
            sort(list, i, rightBound); 
        } 
    } 
 
    public static void swap(int[] list, int a, int b) { 
        int temp = list[a]; 
        list[a] = list[b]; 
        list[b] = temp; 
    } 
 
    public static void printList(int[] input) { 
        for (int i = 0; i < input.length; i++) { 
            System.out.print(input[i] + " "); 
        } 
        System.out.println(); 
    } 
}