Can you do .sort with numbers within strings? | SoloLearn: Learn to code for FREE!

+1

Can you do .sort with numbers within strings?

Example: array=['6','72','24'] array.sort() So is array now ['6','24','72']? If so.... How can I do the same with: ['Name1:6','Othername:72','Andanother:24'] All help appreciated.

12/2/2017 4:59:26 PM

Max S

5 Answers

New Answer

+3

I think that you can put the second array in a dictionary and then try

+3

Good luck and tell us if you succeed!

+3

There is an explanation here: https://www.pythoncentral.io/how-to-sort-python-dictionaries-by-key-or-value/

+1

Ok I will.

0

One more question for everyone: How do you sort the values in a dictionary?