quicksort

import random
import time

list = []
print("Liste wird erstellt\n")

for i in range(10000001):
    rand = random.randint(1, 10000001)
    list.append(rand)
if len(list)%2 != 0:
    list.append(0)

def sort(list,first,last):
   pivot = list[first]
   left = first + 1
   right = last
   done = False

   while not done:
       while left <= right and list[left] <= pivot:
           left = left + 1

       while list[right] >= pivot and right >= left:
           right = right - 1

       if right < left:
           done = True
           
       else:
           temp = list[left]
           list[left] = list[right]
           list[right] = temp

   temp = list[first]
   list[first] = list[right]
   list[right] = temp
   return right

def quick(list,first,last):
   if first<last:
       splitpoint = sort(list, first, last)
       quick(list, first, splitpoint-1)
       quick(list, splitpoint + 1, last)



print(" Sortieren starten\n")
print(list)
start = time.time()
quick(list,0,len(list)-1)
ende = time.time()
print(list)

print('Das Sortieren dauerte {:5.10f} sekunden.'.format(ende-start))