Question about lambda function as a key

Screen Link:

Hello, I don’t understand why the lambda function is used as a key in hn_sorted_points
Normally I have a feeling why a certain solution is used, but here I don’t feel like I get it, can someone please explain to me?

hn_sorted_points = sorted(hn_clean, key=lambda d: d['points'], reverse=True)
top_5_titles = [d['title'] for d in hn_sorted_points[:5]]

@LuukvanVliet the key is argument which expects a function to determine the sorting order.

1 Like