Skip to content

Instantly share code, notes, and snippets.

@alphaCoder
Last active September 14, 2019 19:41
Show Gist options
  • Save alphaCoder/b97167fea232669331db8e1cd0064456 to your computer and use it in GitHub Desktop.
Save alphaCoder/b97167fea232669331db8e1cd0064456 to your computer and use it in GitHub Desktop.
Re order log files
class Solution:
def reorderLogFiles(self, logs: List[str]) -> List[str]:
digits = []
letters = []
for log in logs:
if log.split()[1].isdigit():
digits.append(log)
else:
letters.append(log)
letters.sort(key=lambda x: x.split()[0])
letters.sort(key=lambda x: x.split()[1:])
return letters + digits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment