Version tag sorting

Write codeEasy16 min

Your task

A release dashboard lists the tags a repository has published and wants them in ascending version order. Every tag is the letter v followed by one, two or three numeric segments separated by dots, for example v3, v1.4 or v2.10.7. A missing segment counts as zero, so v7 and v7.0.0 name the same version. Compare segment by segment as numbers rather than as text: v2.9.0 comes before v2.10.0 because 9 is less than 10, even though the raw strings say otherwise. Leading zeros carry no meaning, so v01.2.0 equals v1.2.0. Return the tags sorted ascending. When two tags name the same version, keep them in the order they arrived. An empty list returns an empty list.

Examples

order_release_tags(tags: list[str]) -> list[str]
Example 1
Inputorder_release_tags(["v2.9.0", "v2.10.0", "v10.0.0", "v2.9.1"])
Output["v2.9.0", "v2.9.1", "v2.10.0", "v10.0.0"]
Example 2
Inputorder_release_tags(["v1.2", "v1.2.0", "v1.1.9"])
Output["v1.1.9", "v1.2", "v1.2.0"]
Example 3
Inputorder_release_tags(["v3"])
Output["v3"]