Skip to content

Instantly share code, notes, and snippets.

@stevedya
Created July 12, 2019 17:49
Show Gist options
  • Save stevedya/d266aac292706dd334ebea29c52e7c9e to your computer and use it in GitHub Desktop.
Save stevedya/d266aac292706dd334ebea29c52e7c9e to your computer and use it in GitHub Desktop.
bubble sort example
def sort(nums):
for i in range(len(nums) - 1, 0, -1):
for j in range(i):
if nums[j] > nums[j + 1]:
temp = nums[j]
nums[j] = nums[j + 1]
nums[j + 1] = temp
nums = [5, 3, 8, 6, 7, 2]
sort(nums)
print (nums)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment