Can I sort text by its numeric value in Python?

后端 未结 6 1946
轮回少年
轮回少年 2020-12-16 01:26

I have dict in Python with keys of the following form:

mydict = {\'0\'     : 10,
          \'1\'     : 23,
          \'2.0\'   : 321,
          \'2.1\'   : 3         


        
6条回答
  •  旧巷少年郎
    2020-12-16 01:49

    There is a nice sorting HOWTO on the python web site: http://wiki.python.org/moin/HowTo/Sorting . It makes a good introduction to sorting, and discusses different techniques to adapt the sorting result to your needs.

提交回复
热议问题