Skip to content

Instantly share code, notes, and snippets.

@edumelzer
Created May 27, 2013 15:37
Show Gist options
  • Select an option

  • Save edumelzer/8de9610ffd80b61f5790 to your computer and use it in GitHub Desktop.

Select an option

Save edumelzer/8de9610ffd80b61f5790 to your computer and use it in GitHub Desktop.
Bubble Sort Python (working)
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