Skip to content

Instantly share code, notes, and snippets.

@cfmonkey
Created November 30, 2010 17:25
Show Gist options
  • Select an option

  • Save cfmonkey/722014 to your computer and use it in GitHub Desktop.

Select an option

Save cfmonkey/722014 to your computer and use it in GitHub Desktop.
bitmap sort
#-*- coding: utf-8 -*-
def bitsort(inlist):
tmplist = list([0] * 100)
for item in inlist:
tmplist[item] = 1
outlist = [i for i, item in enumerate(tmplist) if item == 1]
return outlist
if __name__ == '__main__':
il = [1, 4, 3, 5, 7, 2, 9, 10, 8]
ol = bitsort(il)
print 'IN: ' ,il
print 'OUT: ' ,ol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment