'''Q5.
Write a Python program to sort (ascending and descending) a dictionary by value.

Original dictionary :  {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
Dictionary in ascending order by value :  [(0, 0), (2, 1), (1, 2), (4, 3), (3, 4)]
Dictionary in descending order by value :  {3: 4, 4: 3, 1: 2, 2: 1, 0: 0}'''
d = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} 
n = {}
temp = 0
for i in d :
    for j in d:
        if d[i] > d[j]:
            temp = d[i]
            d[i] = d[j]
            d[j] = temp
print(d)
    