@tecnocoia/

quicksort

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
def quick_sort(vector):
  if not vector:
    return []
  else:
    pivote = vector[-1]
    menor = [x for x in vector     if x <  pivote]
    mas_grande = [x for x in vector[:-1] if x >= pivote]
    return quick_sort(menor) + [pivote] + quick_sort(mas_grande)

vector1 = [3,2,5,7]
print(quick_sort(vector1))