python 정렬

Haein Kim·2021년 9월 19일
0

TIL

목록 보기
8/14
In [33]: a=[7,2,5,1,3]

In [34]: a.sort()

In [35]: a
Out[35]: [1, 2, 3, 5, 7]

In [36]: b=['saw', 'small', 'He', 'foxes', 'six']

In [37]: b.sort(key=len)

In [38]: b
Out[38]: ['He', 'saw', 'six', 'small', 'foxes']
In [39]: import bisect

In [40]: c=[1,2,2,2,3,4,7]

In [41]: bisect.bisect(c,2)
Out[41]: 4

In [42]: bisect.bisect(c,5)
Out[42]: 6

In [43]: bisect.insort(c,6)

In [44]: c
Out[44]: [1, 2, 2, 2, 3, 4, 6, 7]
profile
콘텐츠를 사랑하는 데이터 분석가

0개의 댓글