Created
May 27, 2013 15:37
-
-
Save edumelzer/8de9610ffd80b61f5790 to your computer and use it in GitHub Desktop.
Bubble Sort Python (working)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print 'Digite os valores a serem ordenados separados por virgula:' | |
| valores = [2,5,3,9,8] | |
| def bubbleSort(numbers): # Bubble Sort Algorithm | |
| nums = list(numbers) | |
| for i in range(len(nums)): | |
| for j in range(i+1, len(nums)): | |
| if numbers[j] < numbers[i]: | |
| numbers[j], numbers[i] = numbers[i], numbers[j] | |
| print numbers | |
| bubbleSort(valores) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment