BLOG main image
분류 전체보기 (42)
잡담 (6)
활용 (17)
language (3)
project (14)
design (2)
자료정리 (0)
결혼 준비 (0)
sarl pyver
sarl pyver
geometry dash apk zippy
geometry dash apk zippy
geometry dash apk full
geometry dash apk full
cheap christian louboutin
cheap christian louboutin
herehoju.com
herehoju.com
229,007 Visitors up to today!
Today 8 hit, Yesterday 212 hit
daisy rss
tistory 티스토리 가입하기!
2013.02.05 09:03

참 쓸데 없는 짓 일지 모르지만 파이썬에서 bubble sort 를 lambda 를 사용해 보았다


#!/usr/local/bin/python
# -*- coding: utf-8 -*-

source = [55, 07, 78, 12, 42]
print source

unsorted = True
f = lambda x, y, _sorted:[x, y, _sorted] if x < y else [y, x, False]
while unsorted:
    unsorted = True
    for element in range(len(source)-1):
        source[element], source[element+1], unsorted = \
            f(source[element], source[element+1], unsorted)

print source


Name
Password
Homepage
Secret

티스토리 툴바