Q:

python: sort list of strings when it's a list of numbers

Newbie here with the python interpreter.
Why am I not able to sort this list of strings?
>>> list = ['296098', '12805', '10445635', '11679960']
>>> print list.sort()
None
>>> print list.sort(key=float)
None

Why isn't python able to sort this list of string for me?

A:

list.sort() mutates the list in place, instead of returning a new list.
>>> list = ['296098', '12805', '10445635', '11679960']
>>> list.sort()
>>> list
['10445635', '11679960', '12805', '296098']

A:

Firstly, list.sort() manipulate the list in place, which means when you call it, the list is already sorted, and the default return value is None
list = ['296098', '12805', '10445635', '11679960']
list.sort()
list
Out[4]: ['10445635', '11679960', '12805', '296098']

Secondly, above is sort by string value, you want to sort by the numerical value, you can use key=int. Remember you can replace int with any custom methods:
list.sort(key=int)
list
Out[6]: ['12805', '296098', '10445635', '11679960']

Last but not least, you should not use list as a variable name, as it's builtin function name already.

