Swift
\nclass Solution {\n    struct Logs {\n        enum LogsType {\n            case letter\n            case digit\n        }\n        let id: String\n        let 
```\nclass Solution {\n    struct Logs {\n        enum LogsType {\n            case letter\n            case digit\n        }\n        let id: String\n        let values: String\n        let logsType: LogsType\n        let origin: String\n        \n        init(_ str: String) {\n            let index = str.firstIndex { $0 == " " }\n            origin = str\n            id = String(str.prefix(upTo: index!))\n            values = String(str.suffix(from: index!))\n            logsType = (Int(String(values.last!)) != nil) ? .digit : .letter\n        }\n    }\n    \n    func reorderLogFiles(_ logs: [String]) -> [String] {\n        let logs = logs.map(Logs.init)\n        var letterLogs = logs.filter { $0.logsType == .letter }\n        let digitLogs = logs.filter { $0.logsType == .digit }\n        \n        letterLogs.sort {\n\t\t\t$0.values == $1.values ? $0.id < $1.id : $0.values < $1.values\n        }\n        \n        return letterLogs.map { $0.origin } + digitLogs.map { $0.origin }\n    }\n}\n```\n\n![image](https://assets.leetcode.com/users/ambykros/image_1552821727.png)\n
[]