Sort versions according to different versioning schemas.
To use as a CLI app:
pipx install versort
To use as a library:
pip install versort
from versort import get_sorter
sorter = get_sorter("pep440")()
print(sorter.sort("v1", "2a1", "2"))
You can call versort
directly, or as a Python module with python -m versort
.
➤ echo 2 2a1 v1 | versort --stdin pep440
v1
2a1
2
➤ versort --reverse pep440 2 2a1 v1
2
2a1
v1
➤ versort --first pep440 2 2a1 v1
v1
➤ python -m versort --reverse --first pep440 2 2a1 v1
2