Submitting solution... Submission: SUCCESSFUL. Completed in: 37 mins, 56 secs.
16 lines
487 B
Python
16 lines
487 B
Python
def solution(l):
|
|
return sorted(l, key=compare)
|
|
|
|
import re
|
|
def compare(ver_str):
|
|
return tuple([int(v) for v in re.split(r'\.', ver_str)])
|
|
|
|
tests = [
|
|
(["1.11", "2.0.0", "1.2", "2", "0.1", "1.2.1", "1.1.1", "2.0"], ["0.1", "1.1.1", "1.2", "1.2.1", "1.11", "2", "2.0", "2.0.0"]),
|
|
(["1.1.2", "1.0", "1.3.3", "1.0.12", "1.0.2"], ["1.0", "1.0.2", "1.0.12", "1.1.2", "1.3.3"]),
|
|
]
|
|
|
|
for i, o in tests:
|
|
result = solution(i)
|
|
print (i, result == o, result, o)
|