Jul-10-2019, 04:54 AM
Below is not an universal approach, but it might be useful:
def key(x): vals = map(int, x.split('.')) vv = [1000, 50, 1] return sum(x * y for x, y in zip(vv, vals)) sorted(['3.1.3', '3.1.1', '3.1.9', '3.2.1', '3.1.10'], key=key)
Output:['3.1.1', '3.1.3', '3.1.9', '3.1.10', '3.2.1']