Sorting with lambda function for a key is not working

Sorting with lambda function for a key is not working if set is in braces why?
eg:
a = [{“a”, 2}, {“b”, 1}, {“c”, 4}]
sorted(a, key = lambda x: x[1]) <- doesn’t work
b =[ (“jatin”, 2), (“b”, 1), (“c”, 4)]
sorted(b, key = lambda x: x[1]) -> works

Curly braces there mean that it is a Set, Now sets in python are unordered collections, hence they do not support indexing, so they will raise an error. Where are tuples are ordered hence they have indexes and can work with the lambda function when applied

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.