## 问一个python问题

```#!/usr/bin/python
#-*-coding:utf8-*-

def get_bignum(x,y):
return x if x > y else y

def bubble_sort(num_list):
num = len(num_list)
result_list = []
for i in range(0,num):
temp = reduce(get_bignum,num_list)
result_list.insert(0,temp)
num_list.remove(temp)
return result_list

num_list = [1,5,8,2]
print bubble_sort(num_list)```

1

#### 引用来自“Java行者”的答案

```#!/usr/bin/env python

a = range(10)

for i in xrange(10):
for j in xrange(9 - i):
if a[j] < a[j+1]:
a[j], a[j+1] = a[j+1], a[j]
print a```

`a, b = b, a`

1

```def qsort(L):
if len(L) <=1 : return L
return qsort([lt for lt in L[1:] if lt < L[0]]) + L[0:1] + \
qsort([ge for ge in L[1:] if ge >= L[0]])
print qsort([5,4,3,222,12,-11])```

@索隆 其实还是循环 那天打字的时候酒喝多了....

0

```#!/usr/bin/env python

a = range(10)

for i in xrange(10):
for j in xrange(9 - i):
if a[j] < a[j+1]:
a[j], a[j+1] = a[j+1], a[j]
print a```

0

```def bubble_sort(num_list):
for i in range(len(num_list)):
for j in range(i+1,len(num_list)):
if num_list[i]>num_list[j]:
num_list[i],num_list[j]=num_list[j],num_list[i]
print(*num_list)```

0

#### 引用来自“苏坡you”的答案

```def bubble_sort(num_list):
for i in range(len(num_list)):
for j in range(i+1,len(num_list)):
if num_list[i]>num_list[j]:
num_list[i],num_list[j]=num_list[j],num_list[i]
print(*num_list)```

```def bubble_sort(a):
length=len(a)
for i in range(length):
for j in range(length-1,i-1,-1):
if a[j]<a[j-1]:
a[j],a[j-1]=a[j-1],a[j]```