forked from ndb796/Python-Competitive-Programming-Team-Notes
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_sort_library.py
More file actions
Latest commit
28 lines (19 loc) · 580 Bytes
/
Copy pathpython_sort_library.py
File metadata and controls
28 lines (19 loc) · 580 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
n=5
''' Python Sort Library (Basic) '''
data= [8, 5, 4, 7, 2]
data.sort()
forxindata:
print(x)
print("---------------")
''' Python Sort Library (Based on a key) '''
data= [(25, 'Na'), (20, 'Kim'), (23, 'Seo'), (28, 'Park'), (20, 'Ahn')]
data.sort(key=lambdax: x[0]) # Stable Sort (When using a key)
forxindata:
print(x)
print("---------------")
''' Python Sort Library '''
data= [(25, 'Na'), (20, 'Kim'), (23, 'Seo'), (28, 'Park'), (20, 'Ahn')]
data.sort() # Non-stable Sort (When not using a key)
forxindata:
print(x)
print("---------------")