Commit 337fc9d2 authored by Ilya Prokhorov's avatar Ilya Prokhorov

lexiCompare implementation

parent e2c7841e
func lexiCompare(_ lhs: String, _ rhs: String) -> Int {
let lhs = Array(lhs)
let rhs = Array(rhs)
let lhs = Array(lhs.unicodeScalars)
let rhs = Array(rhs.unicodeScalars)
print(lhs)
......@@ -8,8 +8,8 @@ func lexiCompare(_ lhs: String, _ rhs: String) -> Int {
if i >= rhs.count {
return 0
}
let lhsSymbol = lhs[i]
let rhsSymbol = rhs[i]
let lhsSymbol = lhs[i].value
let rhsSymbol = rhs[i].value
if lhsSymbol < rhsSymbol {
return -1
......
/home/demensdeum/Apps/swift5/usr/bin/swift lexicographicSort.swift
/home/demensdeum/Apps/swift5/usr/bin/swift lexiCompare.swift
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment