Let's suppose we have the following list containing some document names:
documents = ['document1.txt', 'document2.txt', 'document3.txt', 'document4.txt', 'document5.txt']
And we also have another python list containing some metric related to the documents above:
metrics = [0.2, 0.55, 0.4, 0.8, 0.4]
where metrics[0]
corresponds to documents[0]
, metrics[1]
to documents[1]
and so on.
Is there any good way to order the list documents
on ascending order based on their corresponding metrics
values?
Output should be:
ordered_documents = ['document1.txt', 'document3.txt', 'document5.txt', 'document2.txt', 'document4.txt']
or
ordered_documents = ['document1.txt', 'document5.txt', 'document3.txt', 'document2.txt', 'document4.txt']