---
# System prepended metadata

title: Untitled

---

arr = [3, 3 ... -2, 1] // n = 1000


arr1 = [4,1,5]
arr2 = [3,2,1]



```python=

def sort(arr):
    if arr.lengh <= 1:
        return arr
    pivot = arr[int(arr.length /2 )]
    left = []
    right = []
    pivot_list = []
    for i, num in enumerate(arr):
        if pivot == num:
            pivot_list.append(num)        
        elif pivot > num:
            left.appnd(num)
        else
            right.appned(num)
        
    left = sort(left)
    right = sort(right)
               
    return left + pivot_list + right

```

```
 [5,4,3,2,1]
      3
      /\
 [2,1]  [5,4]
   2       5
 /  |    / |
[1] |  [4] |
 \  |    \ |
 [1,2]  [4,5]
  \      /
  [1,2,3,4,5]
```