Created
September 24, 2021 06:08
-
-
Save SaraM92/b50dbe1d1957e6d3e0b5f352cc0f9390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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