-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorting.py
More file actions
27 lines (18 loc) · 690 Bytes
/
sorting.py
File metadata and controls
27 lines (18 loc) · 690 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
""""
This module practice working with sorting lists, tuples, dictionaries
"""
nums = [5, 3, 6, 2, 1, 7, 8, 12, 10]
sorted_nums = sorted(nums)
print(f"Sorted Nums: {sorted_nums}")
print(f"Original Nums: {nums}")
nums = (5, 3, 6, 2, 1, 7, 8, 12, 10)
sorted_nums = sorted(nums)
print(f"Sorted Nums: {sorted_nums}")
print(f"Original Nums: {nums}")
persons = {"name": ["Ali", "Zahra", "Hamid"], "age": [30, 25, 28]}
sorted_persons = sorted(persons)
print(f"Sorted Persons: {sorted_persons}") # Sort Keys
print(f"Original Persons: {persons}")
sorted_persons = sorted(persons.items())
print(f"Sorted Persons: {sorted_persons}") # Sort based on keys
print(f"Original Persons: {persons}")