repl.it
@acwoss/

MellowInbornColt

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import random

vector = [random.randrange(0, 9) for _ in range(10)]

def quick_sort(vector):
  # Se o vetor tiver comprimento 1, terminou a ordenação:
  if len(vector) <= 1:
    return vector
  else:
    return quick_sort([x for x in vector[1:] if x < vector[0]]) + \
           [vector[0]] + \
           quick_sort([x for x in vector[1:] if x>=vector[0]])

print(quick_sort(vector))
?