Created
September 19, 2011 19:30
-
-
Save kra3/1227345 to your computer and use it in GitHub Desktop.
mapped dict for sorting
This file contains 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
mapping_tbl = [] | |
mapping_tbl.insert(0, lambda x: int(m.parseString(x).childNodes[0].childNodes[0].nodeValue)) | |
mapping_tbl.insert(1, lambda x: x.lower()) | |
mapping_tbl.insert(2, lambda x: x.lower()) | |
mapping_tbl.insert(3, lambda x: int(x)) | |
mapping_tbl.insert(4, lambda x: datetime.strptime(x, "%m/%d/%Y")) | |
mapping_tbl.insert(5, lambda x: int(x.replace('-', ''))) | |
mapping_tbl.insert(6, lambda x: datetime.strptime(x, "%m/%d/%Y")) | |
mapping_tbl.insert(7, lambda x: datetime.strptime(x, "%m/%d/%Y")) | |
mapping_tbl.insert(8, lambda x: x.lower()) | |
mapping_tbl.insert(9, lambda x: x.lower()) | |
search_data = sorted(search_data, key=cmp_to_key(column_to_sort, mapping_tbl[column_to_sort]), reverse = (sort_dir != "asc")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment