Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sorted set in python

# List
list_of_items = ['g', 'e', 'e', 'k', 's']
print(sorted(list_of_items))
 
# Tuple
tuple_of_items = ('g', 'e', 'e', 'k', 's')
print(sorted(tuple_of_items))
 
# String-sorted based on ASCII
# translations
string = "geeks"
print(sorted(string))
 
# Dictionary
dictionary = {'g': 1, 'e': 2, 'k': 3, 's': 4}
print(sorted(dictionary))
 
# Set
set_of_values = {'g', 'e', 'e', 'k', 's'}
print(sorted(set_of_values))
 
# Frozen Set
frozen_set = frozenset(('g', 'e', 'e', 'k', 's'))
print(sorted(frozen_set))
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #sorted #set #python
ADD COMMENT
Topic
Name
7+4 =