Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sort map by key

 # Declare hash function
    key_value = {}
 
# Initializing value
    key_value[2] = 56
    key_value[1] = 2
    key_value[5] = 12
    key_value[4] = 24
    key_value[6] = 18
    key_value[3] = 323
 
    print("key_value", key_value)
 
    # iterkeys() returns an iterator over the
    # dictionary’s keys.
    for i in sorted(key_value.keys()):
        print(i, end=" ")
# Task 1:-

# key_value {2: 56, 1: 2, 5: 12, 4: 24, 6: 18, 3: 323}

# 1 2 3 4 5 6 
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #python #sort #map #key
ADD COMMENT
Topic
Name
3+8 =