Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created September 24, 2021 06:08
Show Gist options
  • Save SaraM92/b50dbe1d1957e6d3e0b5f352cc0f9390 to your computer and use it in GitHub Desktop.
Save SaraM92/b50dbe1d1957e6d3e0b5f352cc0f9390 to your computer and use it in GitHub Desktop.
a = ['blue', 'green', 'orange', 'purple', 'yellow']
b = [3, 2, 5, 4, 1]
#Use list comprehensions to sort these lists
sortedList = [val for (_, val) in sorted(zip(b, a), key=lambda x: \
x[0])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment