Last active
August 15, 2017 01:15
-
-
Save junyixin/3fd36089316cda208e56b4629f59bdd7 to your computer and use it in GitHub Desktop.
冒泡排序(Python)
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
# buble sort | |
def bubleSort(arrList): | |
for passnum in range(len(arrList)-1, 0, -1): | |
for i in range(passnum): | |
if arrList[i] > arrList[i+1]: | |
temp = arrList[i] | |
arrList[i] = arrList[i+1] | |
arrList[i+1] = temp | |
return arrList | |
# test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment