Write a program that can sort a given dictionary either by key or value in ascending order. The program allows users to choose operations (1: sort by key, 2: sort by value). If the given dictionary is: d = {'x': 7, 'y': 2, 'a': 3, 'm': 2}, the running output is following.
please select operation: (1: sort by key, 2: sort by value) 1
a,3
m,2
x,7
y,2
please select operation: (1: sort by key, 2: sort by value) 2
y,2
m, 2
a,3
x,7
Hint: For "sort by value", consider the function sorted(). Tutorial of sorted() function:
https://towardsdatascience.com/sorting-a-dictionary-in-python-4280451e1637
https://careerkarma.com/blog/python-sort-a-dictionary-by-value/
https://www.geeksforgeeks.org/python-sort-python-dictionaries-by-key-or-value/