Bubble Sorting Python3

import signal
import sys

def sort(input):
    total = 0
    isSorted = False
    ran = len(input) - 1
    while not isSorted:
        isSorted = True
        for j in range(0,ran):
            total +=1
            if input[j] > input[j+1]:
                isSorted = False
                tmp = input[j]
                input[j] = input[j+1]
                input[j+1] = tmp
        ran -= 1

def signal_handler(signal, frame):
        print('You pressed Ctrl+C!')

def main():
    signal.signal(signal.SIGINT, signal_handler)
    print('Press Ctrl+C to stop, input the array split with space')
    for line in sys.stdin:
        arr = [int(elem) for elem in line.split()]

if __name__ == "__main__": main()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s