Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
mapped dict for sorting
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