Python | Custom Log Class | Readable Code
This question is being asked lately a lot by Amazon.\n\nThey want to see custom class creation, and OOP wherever possible.\n\nRead the code, it\'s super clean.\
This question is being asked lately a lot by Amazon.\n\nThey want to see custom class creation, and OOP wherever possible.\n\nRead the code, it\'s super clean.\n\n```\nclass Log:\n    def __init__(self, log: str):\n        log_split = log.split(" ")\n        \n        self.original_log = log\n        self.identifier = log_split[0]\n        self.log_type = "digit" if log_split[1].isnumeric() else "letter"\n        self.log_text = " ".join(log_split[1:])\n        \n    # Custom lower than function for sorting.\n    def __lt__(self, other):\n        if self.log_text == other.log_text:\n            return self.identifier < other.identifier\n        return self.log_text < other.log_text\n        \n        \n\nclass Solution:\n    def reorderLogFiles(self, logs: List[str]) -> List[str]:\n        formatted_logs = [Log(log) for log in logs]\n        letter_logs = [formatted_log for formatted_log in formatted_logs if formatted_log.log_type == "letter"]\n        digit_logs = [formatted_log for formatted_log in formatted_logs if formatted_log.log_type == "digit"]\n        return [log.original_log for log in [*sorted(letter_logs), *digit_logs]]\n```
['Python']