Package managers sort versions like 1.10.0 above 1.9.0, which string sorting gets wrong, and know that a pre-release such as 2.0.0-rc.1 comes before 2.0.0.
Implement parse_version(v) returning a tuple you can compare, compare(a, b) returning -1, 0 or 1, and sort_versions(versions). Follow the core SemVer rules:
MAJOR.MINOR.PATCH, compared numerically. An optional leading v is allowed.-, with dot-separated identifiers. A version with a pre-release is lower than the same version without one.+ is ignored.Raise ValueError for malformed versions.