-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorting_py.py
More file actions
23 lines (23 loc) · 834 Bytes
/
sorting_py.py
File metadata and controls
23 lines (23 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'''
@Author : Md. Shamimul Islam
@Written : 12/02/2019
@Description: python Sorting
'''
a=[8,9,3,2,5,4,1,6,7]
print('sorting the list:{0}'.format(a))
b=['all','izz','ok']
b.sort(key=len)
print('Sorting by word length:{0}'.format(b))
import bisect
"""
The built-in bisect module implements binary search and insertion into a sorted list.
bisect.bisect finds the location where an element should be inserted to keep it sor‐
ted, while bisect.insort actually inserts the element into that location
#it do only correctly work in sorted list
"""
c=[1,2,2,2,3,4,5,6,7]
print(bisect.bisect(c,8))
bisect.insort(c,3)
print(c)
print('Original list is:{} \nSorted list is:{}'.format([8,94,3,2,6,7,1],sorted([8,94,3,2,6,7,1])))
print('Original list is:{} \nSorted list is:{}'.format('bangladesh agiyejao'),sorted['bangladesh agiyejao'))