# Write a Python program to Sort by Frequency of second element in Tuple List # Python3 code to demonstrate working of # Sort by Frequency of second element in Tuple List# Using sorted() + loop + defaultdict() + lambdafrom collections import defaultdict  # initializing listtest_list = [(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]  # printing original listprint("The original list is : " + str(test_list))  # constructing mappingfreq_map = defaultdict(int)for idx, val in test_list:    freq_map[val] += 1  # performing sort of result res = sorted(test_list, key = lambda ele: freq_map[ele[1]], reverse = True)  # printing resultsprint("Sorted List of tuples : " + str(res))