#---------------#
# bubblesort    #
#C=ZAW          #
#V1.0           #
#f=bubblesort.py#
#---------------#
import random
import time
#define function#
def drucken(array):
    i=0
    zeile = 1
    spalte = 1
    while zeile < (elements/40)+1:
        while spalte < 41:
            print(str(array[i]).rjust(4, ' '), end=" ",)
            spalte += 1
            i+=1
        zeile += 1
        spalte = 1
        print(" ")
    print(" ")
#--------------control------------------
TEST=0      #print/noprint array
DIRECTION=1  #sort descending/ascending
elements=30000 #elements in array
#---------------------------------------
zeile = 1
spalte = 1
i=0
array=[]
ch=1
temp=0
anzloop=0
anzch=0
print("+----------------------+")
print("I BUBBLESORT in Python I")
print("+----------------------+")
print("+------------------------------+")
print("   Unsortiert,",elements,"Elemente")
print("+------------------------------+")
while i <elements:
    array.append(random.randint(1, elements))
    i+=1
if TEST : drucken(array)
if TEST: print("+------------------------------+")
print("       Erstellung beendet")
print("+------------------------------+")
print("       Start Sorierung")
print("    ",time.strftime("%d.%m.%Y %H:%M:%S"))
print("+------------------------------+")
#Python hat einen Befehl zum Sortieren von Arrays(Listen)
#: array.sort()  =ASC  oder array.reverse() = DESC 
array.sort()
print("     Sorierung beendet")
print("    ",time.strftime("%d.%m.%Y %H:%M:%S"))
print("+------------------------------+")
if TEST : drucken(array)
print("+------------------------------+")
print("ENDE")



