Missing code of the introduction chapter

Author: JBPressacCreated Aug 29, 2017Updated Apr 15, 2023

Hello, The following code is not present at the end of the FINDING KEY CONNECTORS section of https://github.com/joelgrus/data-science-from-scratch/blob/master/code/introduction.py:

num_friends_by_id = [(user["id"], number_of_friends(user)) for user in users]
sorted(num_friends_by_id,
       key= lambda (user_id, num_friends): num_friends,
       reverse=True)

For the Python 3 version, I propose the following solution to take the PEP 3113 into account:

num_friends_by_id = [(user["id"], number_of_friends(user)) for user in users]
sorted(num_friends_by_id,
       key= lambda userid_numfriends: userid_numfriends[1],
       reverse=True)

Source: joelgrus/data-science-from-scratch