One option is to use from distutils.version import LooseVersion, but that doesn't like 'None', 'Sure.0':
all_versions.sort(key=LooseVersion)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/version.py", line 52, in __lt__
c = self._cmp(other)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/version.py", line 337, in _cmp
if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'
Instead, we can use natsort which deals with '3.10', 'None', 'Sure.0':
The lists of versions includes a
'3.10'
andsorted(all_versions)
puts them in alphabetical order as'3.1', '3.10', '3.2'
:One option is to use
from distutils.version import LooseVersion
, but that doesn't like'None', 'Sure.0'
:Instead, we can use natsort which deals with
'3.10', 'None', 'Sure.0'
: