sort_versions()

audeer.sort_versions(versions)[source]

Sort version numbers.

If a version starts with v, the v is ignored during sorting.

Parameters

versions (List[str]) – sequence with semantic version numbers

Return type

List

Returns

sorted list of versions with highest as last entry

Raises

ValueError – if the version does not comply with is_semantic_version()

Examples

>>> vers = [
...     "2.0.0",
...     "2.0.1",
...     "v1.0.0",
...     "v2.0.0-1-gdf29c4a",
... ]
>>> sort_versions(vers)
['v1.0.0', '2.0.0', 'v2.0.0-1-gdf29c4a', '2.0.1']