Created
November 5, 2015 06:21
-
-
Save nathan-osman/61e55345b1b62006a515 to your computer and use it in GitHub Desktop.
Sort a list of version numbers
This file contains 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
#!/usr/bin/env python2 | |
from argparse import ArgumentParser | |
from apt_pkg import init_system, version_compare | |
if __name__ == '__main__': | |
parser = ArgumentParser(description="Sort a list of version numbers") | |
parser.add_argument( | |
'versions', | |
metavar='VERSIONS', | |
nargs='+', | |
type=str, | |
help='list of version numbers', | |
) | |
args = parser.parse_args() | |
init_system() | |
for v in sorted(args.versions, cmp=version_compare): | |
print v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment