diff --git a/nodeenv.py b/nodeenv.py
index c00a75c..ec9e358 100644
--- a/nodeenv.py
+++ b/nodeenv.py
@@ -36,13 +36,15 @@ except ImportError:  # pragma: no cover (py3 only)
 
 from pkg_resources import parse_version
 
-
 nodeenv_version = '0.13.0'
 
 join = os.path.join
 abspath = os.path.abspath
 src_domain = "nodejs.org"
 
+is_PY3 = sys.version_info[0] == 3
+if is_PY3:
+    from functools import cmp_to_key
 # ---------------------------------------------------------
 # Utils
 
@@ -711,20 +713,58 @@ def create_environment(env_dir, opt):
         callit(['rm -rf', pipes.quote(src_dir)], opt.verbose, True, env_dir)
 
 
+class GetsAHrefs(HTMLParser):
+    def __init__(self):
+        # Old style class in py2 :(
+        HTMLParser.__init__(self)
+        self.hrefs = []
+
+    def handle_starttag(self, tag, attrs):
+        if tag == 'a':
+            self.hrefs.append(dict(attrs).get('href', ''))
+
 VERSION_RE = re.compile('\d+\.\d+\.\d+')
 
 
+def _py2_cmp(a, b):
+    # -1 = a < b, 0 = eq, 1 = a > b
+    return (a > b) - (a < b)
+
+
+def compare_versions(version, other_version):
+    version_tuple = version.split('.')
+    other_tuple = other_version.split('.')
+
+    version_length = len(version_tuple)
+    other_length = len(other_tuple)
+    version_dots = min(version_length, other_length)
+
+    for i in range(version_dots):
+        a = int(version_tuple[i])
+        b = int(other_tuple[i])
+        cmp_value = _py2_cmp(a, b)
+        if cmp_value != 0:
+            return cmp_value
+
+    return _py2_cmp(version_length, other_length)
+
+
 def get_node_versions():
     response = urlopen('https://{0}/dist'.format(src_domain))
     href_parser = GetsAHrefs()
     href_parser.feed(response.read().decode('UTF-8'))
+
     versions = set(
         VERSION_RE.search(href).group()
         for href in href_parser.hrefs
         if VERSION_RE.search(href)
     )
-    sorted_versions = sorted([parse_version(version) for version in versions])
-    return [v.public for v in sorted_versions]
+    if is_PY3:
+        key_compare = cmp_to_key(compare_versions)
+        versions = sorted(versions, key=key_compare)
+    else:
+        versions = sorted(versions, cmp=compare_versions)
+    return versions
 
 
 def print_node_versions():
@@ -739,17 +779,6 @@ def print_node_versions():
         logger.info('\t'.join(chunk))
 
 
-class GetsAHrefs(HTMLParser):
-    def __init__(self):
-        # Old style class in py2 :(
-        HTMLParser.__init__(self)
-        self.hrefs = []
-
-    def handle_starttag(self, tag, attrs):
-        if tag == 'a':
-            self.hrefs.append(dict(attrs).get('href', ''))
-
-
 def get_last_stable_node_version():
     """
     Return last stable node.js version

nodeenv --list is raising TypeError
When installed globally with `sudo pip install nodeenv`, `nodeenv --list` raises an exception.

This is due to `pkg_resources.parse_version` method having different return types in older versions. 

![nodeenv_bug](https://cloud.githubusercontent.com/assets/6031925/6599860/d253a2b0-c814-11e4-94d6-9a9d79cdf27c.png)


Possible hotfix solutions are:
* write a helper function to parse strings,
* write our own Version type :-1: 

But atm I'm working on finding out which version of `setuptools` introduced the newer (currently used in master) Version type that parses version strings and rely on it if `setuptools` is >= that version.

I'll combine that with one of two approaches:
* the raw string representation we get with regex pattern. However ascending sorting will be `0.1.0, 0.10.0, 0.9.0`,
*  the before mentioned helper function


I think broken ascending sort is acceptable as a hotfix.

PR will be submitted soon-ish. :8ball: 
diff --git a/tests/nodeenv_test.py b/tests/nodeenv_test.py
index 8c8b163..f13b219 100644
--- a/tests/nodeenv_test.py
+++ b/tests/nodeenv_test.py
@@ -14,6 +14,17 @@ import nodeenv
 HERE = os.path.abspath(os.path.dirname(__file__))
 
 
+def test_compare_versions():
+    assert nodeenv.compare_versions('1', '2') == -1
+    assert nodeenv.compare_versions('1', '2') == -1
+    assert nodeenv.compare_versions('0.1', '0.2') == -1
+    assert nodeenv.compare_versions('0.9', '0.10') == -1
+    assert nodeenv.compare_versions('0.2', '0.2.1') == -1
+    assert nodeenv.compare_versions('0.2.1', '0.2.10') == -1
+    assert nodeenv.compare_versions('0.2.9', '0.2.10') == -1
+    assert nodeenv.compare_versions('0.2.1', '0.3') == -1
+
+
 def test_gets_a_hrefs_trivial():
     parser = nodeenv.GetsAHrefs()
     parser.feed('')

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-django pytest-cov pytest-localserver pytest-mock pytest-benchmark pytest-bdd pytest-rerunfailures jsonschema more-itertools pluggy atomicwrites pyrsistent configparser contextlib2 importlib-metadata packaging Mako glob2 parse parse-type toml iniconfig docutils py-cpuinfo urllib3 certifi Logbook WebOb argparse greenlet mock msgpack-python pep8 pytz ecs_logging structlog pytest-asyncio asynctest typing_extensions
apt-get update apt-get install -y gcc
3.9
tests/requirements/reqs-base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
asynctest==0.13.0
atomicwrites==1.4.1
attrs==25.3.0
certifi==2025.1.31
configparser==7.2.0
contextlib2==21.6.0
coverage==7.8.0
docutils==0.21.2
ecs-logging==2.2.0
exceptiongroup==1.2.2
gherkin-official==29.0.0
glob2==0.7
greenlet==3.1.1
importlib_metadata==8.6.1
iniconfig==2.1.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
Logbook==1.8.1
Mako==1.3.9
MarkupSafe==3.0.2
mock==5.2.0
more-itertools==10.6.0
msgpack-python==0.5.6
-e git+https://github.com/ekalinin/nodeenv.git@677df66038d8ef2a5180a41e8335a857af5494f0#egg=nodeenv
packaging==24.2
parse==1.20.2
parse_type==0.6.4
pep8==1.7.1
pluggy==1.5.0
py-cpuinfo==9.0.0
pyrsistent==0.20.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-bdd==8.1.0
pytest-benchmark==5.1.0
pytest-cov==6.0.0
pytest-django==4.10.0
pytest-localserver==0.9.0.post0
pytest-mock==3.14.0
pytest-rerunfailures==15.0
pytz==2025.2
referencing==0.36.2
rpds-py==0.24.0
six==1.17.0
structlog==25.2.0
toml==0.10.2
tomli==2.2.1
typing_extensions==4.13.0
urllib3==2.3.0
WebOb==1.8.9
Werkzeug==3.1.3
zipp==3.21.0

name: nodeenv
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argparse==1.4.0
      - asynctest==0.13.0
      - atomicwrites==1.4.1
      - attrs==25.3.0
      - certifi==2025.1.31
      - configparser==7.2.0
      - contextlib2==21.6.0
      - coverage==7.8.0
      - docutils==0.21.2
      - ecs-logging==2.2.0
      - exceptiongroup==1.2.2
      - gherkin-official==29.0.0
      - glob2==0.7
      - greenlet==3.1.1
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - logbook==1.8.1
      - mako==1.3.9
      - markupsafe==3.0.2
      - mock==5.2.0
      - more-itertools==10.6.0
      - msgpack-python==0.5.6
      - packaging==24.2
      - parse==1.20.2
      - parse-type==0.6.4
      - pep8==1.7.1
      - pluggy==1.5.0
      - py-cpuinfo==9.0.0
      - pyrsistent==0.20.0
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-bdd==8.1.0
      - pytest-benchmark==5.1.0
      - pytest-cov==6.0.0
      - pytest-django==4.10.0
      - pytest-localserver==0.9.0.post0
      - pytest-mock==3.14.0
      - pytest-rerunfailures==15.0
      - pytz==2025.2
      - referencing==0.36.2
      - rpds-py==0.24.0
      - six==1.17.0
      - structlog==25.2.0
      - toml==0.10.2
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - webob==1.8.9
      - werkzeug==3.1.3
      - zipp==3.21.0
prefix: /opt/conda/envs/nodeenv

tests/nodeenv_test.py::test_compare_versions
tests/nodeenv_test.py::test_smoke
tests/nodeenv_test.py::test_gets_a_hrefs_trivial tests/nodeenv_test.py::test_gets_a_hrefs_nodejs_org tests/nodeenv_test.py::test_gets_a_hrefs_iojs_org tests/nodeenv_test.py::test_get_node_versions_iojs tests/nodeenv_test.py::test_get_node_versions_nodejs tests/nodeenv_test.py::test_print_node_versions_iojs tests/nodeenv_test.py::test_print_node_versions_node
nodeenv.py
nodeenv.py