#!/usr/bin/python
#-*-coding:UTF-8-*-
#冒泡
排序算法
def sortNum(numlist):
_numlen = len(numlist)
for _num1 in xrange(_numlen - 1,0,-1):
for _num2 in xrange(_num1 - 1,-1,-1):
if numlist[_num1] < numlist[_num2]:
(numlist[_num1],numlist[_num2]) = (numlist[_num2],numlist[_num1])
if __name__ == '__main__':
a = [1,4,-12,100,3,9,7,87,7,6,12,]
print "sort previous: ",
for iter in a:
print iter,
sortNum(a)
print "nafter sorted: ",
for i in a:
print i,