-
-
Save antiface/80f06c486578e3189fecdddbf6566c1a to your computer and use it in GitHub Desktop.
bitmap sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #-*- 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