Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort versions chronologically #134

Merged
merged 5 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion solc_select/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
halt_old_architecture,
upgrade_architecture,
)
from .utils import sort_versions


# pylint: disable=too-many-branches
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions solc_select/utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)
Loading