I wrote these snippets for version comparison and they are not in good quality but enough for me.
The following code is an implementation which compare arithmetically and alphabetically:
But I later found it can’t return the correct result I expect for 1.0 and 1.0rc1. So, I decided to strip and made a simplified version, it will die hard when non-digits are supplied.
I think there is another quick way to compare, using sort -V. sort can sort version strings, too. You feed it with two lines of version strings, then see which is returned first. But, I don’t think it covers all strange versioning schemes.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.