a faster and simpler solution, assuming you are on unix, is to just use the sort command:
spl6 tmp: cat 1- 1 74 0 0 6 0 1 78 0 0 4 0 1 89 0 0 0 2 spl6 tmp: cat 1+ 1 73 0 1 0 0 1 76 1 0 0 0 1 77 0 1 0 0 spl6 tmp: sort -n -k 2,2 1[-+] 1 73 0 1 0 0 1 74 0 0 6 0 1 76 1 0 0 0 1 77 0 1 0 0 1 78 0 0 4 0 1 89 0 0 0 2 bash can also iterate over files trivially. you do not need python for this. andrew -- http://mail.python.org/mailman/listinfo/python-list