input: Write a python function to implement quicksort algorithm.
  assert quicksort([3, 8, 1, 9, 5, 2]) == [1, 2, 3, 5, 8, 9]
  assert quicksort([5, 3, 8, 6, 7, 2]) == [2, 3, 5, 6, 7, 8]
  assert quicksort([10, 7, 8, 9, 1, 5]) == [1, 5, 7, 8, 9, 10]
  assert quicksort([1]) == [1]
  assert quicksort([]) == []
  
  Write a python function to implement mergesort algorithm.
  assert mergesort([3, 8, 1, 9, 5, 2]) == [1, 2, 3, 5, 8, 9]
  assert mergesort([5, 3, 8, 6, 7, 2]) == [2, 3, 5, 6, 7, 8]
  assert mergesort([10, 7, 8, 9, 1, 5]) == [1, 5, 7, 8, 9, 10]
  assert mergesort([1]) == [1]
  assert mergesort([]) == []
output: def quicksort(arr):
      if len(arr) <= 1:
          return arr
      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:
          return arr
      mid = len(arr) // 2
      left = mergesort(arr[:mid])
      right = mergesort(arr[mid:])
      return merge(left, right)
  
  def merge(left, right):
      result = []
      i = j = 0
      while i < len(left) and j < len(right):
          if left[i] < right[j]:
              result.append(left[i])
              i += 1
          else:
              result.append(right[j])
              j += 1
      result.extend(left[i:])
      result.extend(right[j:])
      return result