I have two lists; say one of fruits and another of equal length but of unordered numbers:
eg:
Fruits = ['apple', 'banana', 'pineapple', 'kiwifruit'],
Numbers = [3, 2, 4, 1]
How can I firstly assign the number
- 3 to apple,
- 2 to banana,
- 4 to pineapple and
- 1 to kiwifruit
and secondly order them according to their new numbers?
i.e
sortedlist = ['kiwifruit', 'banana', 'apple', 'pineapple'].
My attempts so far have included the enumerate function and the sorted function, but I can't seem to assign and then sort.