# Richard Caban 2015 '''OUTPUT "Enter a list of numbers to sort in square brackets:" INPUT data Sort the data OUTPUT data ''' data = input("Enter a list of numbers to sort in square brackets:") # Sort the data firstUnsorted = 0 while len(data) != 0: while firstUnsorted < (len(data) - 1): # data[firstUnsorted] = smallest unsorted item compare = firstUnsorted while compare < len(data): # if data[firstUnsorted] > data[compare] if data[firstUnsorted] > data[compare]: #Swap firstUnsorted item with the smallest temp = data[firstUnsorted] data[firstUnsorted] = data[compare] data[compare] = temp '''print data''' compare = compare + 1 '''print "comparing", firstUnsorted, "with", compare''' firstUnsorted = firstUnsorted + 1 '''print "first unsorted is at position", firstUnsorted''' print data data = input("Enter a list of numbers to sort in square brackets:") firstUnsorted = 0 print 'Bye Now!'
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question