source: lliurex-maker/trunk/fuentes/new/usr/bin/sort_by_version @ 7500

Last change on this file since 7500 was 7500, checked in by kbut, 2 years ago

fix sort function

  • Property svn:executable set to *
File size: 406 bytes
Line 
1#!/usr/bin/env python
2import apt_pkg
3import sys
4import functools
5import fileinput
6cmp = functools.cmp_to_key(apt_pkg.version_compare)
7apt_pkg.init_system()
8
9list_packages = sys.stdin.readlines()
10if len(list_packages) > 0:
11    list_packages = map(lambda x: x.strip(),list_packages)
12if len(sys.argv[1:0]) > 0:
13    list_packages = sys.argv[1:]
14list_packages.sort(key=cmp)
15for x in list_packages:
16    print(x)
Note: See TracBrowser for help on using the repository browser.