Skip to content

Instantly share code, notes, and snippets.

@hongdonghyun
Created May 24, 2017 02:06
Show Gist options
  • Save hongdonghyun/a1173fdd441a17d52ccd7a2cd1cf65b0 to your computer and use it in GitHub Desktop.
Save hongdonghyun/a1173fdd441a17d52ccd7a2cd1cf65b0 to your computer and use it in GitHub Desktop.
버블버블
import random
random_list = [random.randint(1,100) for i in range(20)]
print('== 버블 정렬 전 리스트 ==\n {}'.format(random_list))
def bubble_sort(input_list):
length =len(input_list) -1
for index in range(length):
for index2 in range(length-index):
if input_list[index2] > input_list[index2+1]:
input_list[index2],input_list[index2+1]=input_list[index2+1],input_list[index2]
return input_list
print('== 버블 정렬 후 리스트 ==\n ')
print(bubble_sort(random_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment