Skip to content

Instantly share code, notes, and snippets.

@jonathanagustin
Created October 9, 2020 13:10
Show Gist options
  • Select an option

  • Save jonathanagustin/483b26d0330d6be658699af2f5c865ba to your computer and use it in GitHub Desktop.

Select an option

Save jonathanagustin/483b26d0330d6be658699af2f5c865ba to your computer and use it in GitHub Desktop.
Custom Sorting In Python
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