def quick_sort(arr, low, high):
if low < high:
pi = partition(arr, low, high)
quick_sort(arr, low, pi - 1)
quick_sort(arr, pi + 1, high)
def partition(arr, low, high):
pivot = arr[high]
i = low - 1
for j in range(low, high):
if arr[j] < pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
lista = [3, 1, 4, 5, 2]
quick_sort(lista, 0, len(lista) - 1)
print("Lista ordenada:", lista)
ZGVmIHF1aWNrX3NvcnQoYXJyLCBsb3csIGhpZ2gpOgogICAgaWYgbG93IDwgaGlnaDoKICAgICAgICBwaSA9IHBhcnRpdGlvbihhcnIsIGxvdywgaGlnaCkKICAgICAgICBxdWlja19zb3J0KGFyciwgbG93LCBwaSAtIDEpCiAgICAgICAgcXVpY2tfc29ydChhcnIsIHBpICsgMSwgaGlnaCkKCmRlZiBwYXJ0aXRpb24oYXJyLCBsb3csIGhpZ2gpOgogICAgcGl2b3QgPSBhcnJbaGlnaF0KICAgIGkgPSBsb3cgLSAxCiAgICBmb3IgaiBpbiByYW5nZShsb3csIGhpZ2gpOgogICAgICAgIGlmIGFycltqXSA8IHBpdm90OgogICAgICAgICAgICBpICs9IDEKICAgICAgICAgICAgYXJyW2ldLCBhcnJbal0gPSBhcnJbal0sIGFycltpXQogICAgYXJyW2kgKyAxXSwgYXJyW2hpZ2hdID0gYXJyW2hpZ2hdLCBhcnJbaSArIDFdCiAgICByZXR1cm4gaSArIDEKCmxpc3RhID0gWzMsIDEsIDQsIDUsIDJdCnF1aWNrX3NvcnQobGlzdGEsIDAsIGxlbihsaXN0YSkgLSAxKQpwcmludCgiTGlzdGEgb3JkZW5hZGE6IiwgbGlzdGEpCg==