Semantic version comparison

Write codeHard28 min

Your task

Implement Semantic Versioning precedence comparison. Each version is 'MAJOR.MINOR.PATCH' optionally followed by '-' and a prerelease string of dot-separated identifiers. Compare core numbers numerically left to right. A version WITH a prerelease has LOWER precedence than the same core WITHOUT one. Prerelease identifiers compare left to right: numeric identifiers compare numerically and rank below alphanumeric ones; alphanumeric compare lexically; if all shared identifiers are equal, the version with MORE identifiers is greater. Return -1, 0, or 1 for v1 < v2, ==, or >.

Examples

semver_compare(v1: str, v2: str) -> int
Example 1
Inputsemver_compare("1.0.0", "1.0.1")
Output-1