# Python implementation of bitsort algorithm from "Programming Pearls"
def bitsort(filename, maxn):
""" Sort a file named 'filename' which
consists of maxn integers where each
integer is less than maxn """
# Initialize bitmap
a = [0]*maxn
# Read from file and fill bitmap
for line in file(filename):
n = int(line.strip())
# Turn bits on for numbers
if n