Created
October 9, 2020 13:10
-
-
Save jonathanagustin/483b26d0330d6be658699af2f5c865ba to your computer and use it in GitHub Desktop.
Custom Sorting In Python
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
| class Solution: | |
| def reorderLogFiles(self, logs: List[str]) -> List[str]: | |
| def get_key(log): | |
| _id, rest = log.split(" ", maxsplit=1) | |
| return (0, rest, _id) if rest[0].isalpha() else (1, ) | |
| return sorted(logs, key=get_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment