Created
July 12, 2019 17:49
-
-
Save stevedya/d266aac292706dd334ebea29c52e7c9e to your computer and use it in GitHub Desktop.
bubble sort example
This file contains 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
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