Skip to content

Instantly share code, notes, and snippets.

@junyixin
Last active August 15, 2017 01:15
Show Gist options
  • Save junyixin/3fd36089316cda208e56b4629f59bdd7 to your computer and use it in GitHub Desktop.
Save junyixin/3fd36089316cda208e56b4629f59bdd7 to your computer and use it in GitHub Desktop.
冒泡排序(Python)
# 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