Write a Python program to compare the results of two sorting algorithms.
Algorithms: QuickSort, MergeSort 
Array: [3, 8, 1, 9, 5, 2]
def quicksort(arr): 
    if len(arr) <= 1:
        return arr
    else:
        pivot = arr[len(arr) // 2]
        left = [x for x in arr if x < pivot]
        middle = [x for x in arr if x == pivot]
        right = [x for x in arr if x > pivot]
        return quicksort(left) + middle + quicksort(right)

def mergesort(arr): 
    if len(arr) > 1: 
        mid = len(arr) // 2   # Finding the mid of the array 
        L = arr[:mid]   # Dividing the array elements  
        R = arr[mid:]   # into 2 halves 
        left_arr = mergesort(L)  # Sorting the first 
        right_arr = mergesort(R) # half 
        arr =[] 
        while len(left_arr) > 0 and len(right_arr) > 0: 
            if left_arr[0] < right_arr[0]: 
                arr.append(left_arr[0]) 
                left_arr.pop(0) 
            else: 
                arr.append(right_arr[0]) 
                right_arr.pop(0) 
        # Checking if any element was left 
        for i in left_arr: 
            arr.append(i) 
        for i in right_arr: 
            arr.append(i) 
        return arr

# Test array 
arr = [3, 8, 1, 9, 5, 2] 
# Sorted array using QuickSort 
print("Sorted array using QuickSort:", quicksort(arr)) 
# Sorted array using MergeSort 
print("Sorted array using MergeSort:", mergesort(arr))

Output:
Sorted array using QuickSort: [1, 2, 3, 5, 8, 9]
Sorted array using MergeSort: [1, 2, 3, 5, 8, 9]