I`m writing a script, where i need to compare versions of binnaries , so for example i need to get 10.2.3 greater than 10.1.30 . If i remove dots, i will get 1023 and 10130, which twists my comparison upside down.
10.2.3 > 10.1.30 == 1023 !> 10130
Till now, the only solution i came out is :
1. do split(".") on version number
2. for each elemet of list i got, check if len() is eq 1 , add one zero from the left.
3. glue all elements together and get int (10.1.30 will became 100130).
4. process second version number same way and compare both as regular ints.
This way :
10.2.3 > 10.1.30 == 100203 > 100130
Is this the only way to compare versions or there are others?