@@ -161,24 +161,24 @@ extension String {
161161
162162 /// Score and compare two string components
163163 ///
164- func compareStringComponent ( stringComponent1 : String , stringComponent2 : String ) -> ComparisonResult {
164+ func compareStringComponents ( _ lhs : String , _ rhs : String ) -> ComparisonResult {
165165 /// Score each component
166- let stringComponent1Score = scoreComponent ( stringComponent: stringComponent1 )
167- let stringComponent2Score = scoreComponent ( stringComponent: stringComponent2 )
166+ let lhsScore = scoreComponent ( stringComponent: lhs )
167+ let rhsScore = scoreComponent ( stringComponent: rhs )
168168
169- if stringComponent1Score < stringComponent2Score {
169+ if lhsScore < rhsScore {
170170 return . orderedAscending
171171 }
172172
173- if stringComponent1Score > stringComponent2Score {
173+ if lhsScore > rhsScore {
174174 return . orderedDescending
175175 }
176176
177- if stringComponent1Score == . number && stringComponent2Score == . number {
178- let component1 = NSNumber ( value: Int ( stringComponent1 ) ?? 0 )
179- let component2 = NSNumber ( value: Int ( stringComponent2 ) ?? 0 )
177+ if lhsScore == . number && rhsScore == . number {
178+ let lhsAsNumber = NSNumber ( value: Int ( lhs ) ?? 0 )
179+ let rhsAsNumber = NSNumber ( value: Int ( rhs ) ?? 0 )
180180
181- let comparisonResult = component1 . compare ( component2 )
181+ let comparisonResult = lhsAsNumber . compare ( rhsAsNumber )
182182 if comparisonResult != . orderedSame {
183183 return comparisonResult
184184 }
@@ -205,7 +205,7 @@ extension String {
205205 let leftComponent = index < leftComponents. count ? leftComponents [ index] : " 0 "
206206 let rightComponent = index < rightComponents. count ? rightComponents [ index] : " 0 "
207207
208- let comparisonResult = compareStringComponent ( stringComponent1 : leftComponent, stringComponent2 : rightComponent)
208+ let comparisonResult = compareStringComponents ( leftComponent, rightComponent)
209209 if comparisonResult != . orderedSame {
210210 return comparisonResult
211211 }
0 commit comments