Skip to content

Instantly share code, notes, and snippets.

@marshall
Created January 8, 2013 12:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marshall/4483399 to your computer and use it in GitHub Desktop.
Save marshall/4483399 to your computer and use it in GitHub Desktop.
Services.vc.compare for different version strings
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]);
}
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