diff --git a/solc_select/__main__.py b/solc_select/__main__.py index fd0964f..6193015 100644 --- a/solc_select/__main__.py +++ b/solc_select/__main__.py @@ -20,6 +20,7 @@ halt_old_architecture, upgrade_architecture, ) +from .utils import sort_versions # pylint: disable=too-many-branches @@ -68,7 +69,7 @@ def solc_select() -> None: res = current_version() if res: (current_ver, source) = res - for version in reversed(sorted(versions_installed)): + for version in sort_versions(versions_installed): if res and version == current_ver: print(f"{version} (current, set by {source})") else: diff --git a/solc_select/utils.py b/solc_select/utils.py index f6312bf..98b7305 100644 --- a/solc_select/utils.py +++ b/solc_select/utils.py @@ -1,6 +1,9 @@ import platform import subprocess import sys +from typing import List + +from packaging.version import Version def mac_can_run_intel_binaries() -> bool: @@ -13,3 +16,8 @@ def mac_can_run_intel_binaries() -> bool: # Intel Mac return True + + +def sort_versions(versions: List[str]) -> List[str]: + """Sorts a list of versions following the component order (major/minor/patch)""" + return sorted(versions, key=Version)