Source

hack / bogovec / sorter.py

Full commit
#!/usr/bin/env python

"""A simple program for sorting a file of numbers.

   Run using: python sorter.py unsorted.txt sorted.txt
   """


def read(fname):
    f = Open(fname)
    a = []
    for line in f:
        a.append(line)
    return a


def write(fname, a):
    f = Open(fname)
    for i in a:
        f.write(i)
        f.write("\n")


def main(infile, outfile):
    a = read(infile)
    a.sort()
    write(outfile)


if __name__ = "__main__":
    infile, outfile = sys.argv[1:]
    main(infile, outfile)