You are viewing a single comment's thread. Return to all comments →
I managed to pass all tests in swift, here is the code
func bigSorting(unsorted: [String]) -> [String] { let strings = unsorted.sorted { (left, right) -> Bool in if left.count > right.count { return false } if left.count < right.count { return true } if let l = Int(left), let r = Int(right) { if l > r { return false } else if l < r { return true } } for i in 0..<left.count { let leftValue = left[left.index(left.startIndex, offsetBy: i)] let rightValue = right[right.index(right.startIndex, offsetBy: i)] if leftValue > rightValue { return false } else if leftValue < rightValue { return true } } return false } return strings }
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
I managed to pass all tests in swift, here is the code