Created
January 8, 2013 12:37
-
-
Save marshall/4483399 to your computer and use it in GitHub Desktop.
Services.vc.compare for different version strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Components.utils.import("resource://gre/modules/Services.jsm"); | |
let versions = [ | |
"1.0", "1.0.0", "1.0.0beta", "1.0.0.1", "1.0.20", "1.0.2.0", "1.1.0.1", | |
"1.1.0", "1.1.0alpha" | |
]; | |
versions.sort(Services.vc.compare); | |
versions.reverse(); | |
for (let i = 0; i < versions.length; i++) { | |
if (i == 0) { | |
print(versions[i]); | |
continue; | |
} | |
print(" > " + versions[i]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.1.0.1 | |
> 1.1.0 | |
> 1.1.0alpha | |
> 1.0.20 | |
> 1.0.2.0 | |
> 1.0.0.1 | |
> 1.0.0 | |
> 1.0 | |
> 1.0.0beta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment