I’m looking for a way to order/sort a set of strings that define software versions, in the following format: x.x.x (e.g.: 1.3.12).
Those strings are in an database(mysql) , but I’m not sure if this is even relevant.
One idea I can think of is to make a String ->integer(or float) conversion and than sort the set by the integer index. However I’m not sure if this is possible.
Also I’m looking for other ideas.
Thanks
UPDATE: I just thought about setting a number which represents the maximum version I could implement(and by version I mean major version,minor version, revision). for example I choose the number 300 , so the maximum version will be 299.299.299
so.. when I convert I can do something like this: major*pow(300,2)+minor*pow(300,1)+revision*pow(300,0)
Still opened to ideas.
Don’t use multidotted strings as strings – you’ll have big headache on compare it’s value
In your case you can (must?) expand version to 4-octets string (with trailing 0) and use IP4-related functions (from frontend or built-in MySQL)
From MySQL manual