3. Write a python program to sort the order of programming based on its alphabet sequence with list of dictionaries, programmer is provided. The expected answer is in the following output for better understanding.
The output is:
programmer =
[{'Name':'Mark', 'Programming':'Python', 'Year of Experience': 3},
{'Name':'Nicole', 'Programming':'C', 'Year of Experience': 1},
{'Name':'Jason', 'Programming':'R', 'Year of Experience': 10}]
Expected Answer:
The initil list of dictionaries :
[{'Name': 'Mark', 'Programming': 'Python', 'Year of Experience': 3},
{'Name': 'Nicole', 'Programming': 'C', 'Year of Experience': 1},
{'Name': 'Jason', 'Programming': 'R', 'Year of Experience': 10}]
After sorting the list of dictionaries :
[{'Name': 'Nicole', 'Programming': 'C', 'Year of Experience': 1},
{'Name': 'Mark', 'Programming': 'Python', 'Year of Experience': 3},
{'Name': 'Jason', 'Programming': 'R', 'Year of Experience': 10}]
Sample Answer:
programmer = [{'Name':'Mark', 'Programming':'Python', 'Year of Experience': 3}, {'Name':'Nicole', 'Programming':'C', 'Year of Experience': 1}, {'Name':'Jason', 'Programming':'R', 'Year of Experience': 10}] print("The initil list of dictionaries :") print(programmer) sorted_programmer = sorted(programmer, key = lambda x: x['Programming']) print("\nAfter sorting the list of dictionaries :") print(sorted_programmer)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)