Created
July 28, 2021 04:14
-
-
Save minusworld/e1af6570d57132963ec49ccfade9764b to your computer and use it in GitHub Desktop.
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
| from collections import defaultdict | |
| def group(items: List[Any], key: Callable[[Any], Any]) -> Dict[Any, Any]: | |
| dd = defaultdict(list) | |
| for item in items: | |
| k = key(item) | |
| dd[k].append(item) | |
| return dd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment