I have a dictionary:
a = {1:10,5:20,3:30,2:5}
Then I put the keys and values into lists.
key = list(a.keys())
value = list(a.values())
Then sort it
sorted(zip(key,value))
>>> [(1, 10), (2, 5), (3, 30), (5, 20)]
If I zip it again
zip(sorted(zip(key,value)))
tuple(zip(sorted(zip(key,value))))
>>> (((1, 10),), ((2, 5),), ((3, 30),), ((5, 20),))
zip(*sorted(zip(key,value)))
tuple(zip(*sorted(zip(key,value))))
>>> ((1, 2, 3, 5), (10, 5, 30, 20))
It looks like with the star(*), the keys and values are grouped separately, where without *, individual (key, value) pairs are grouped together. Can someone explain what the * does in here?