Numbers within strings are compared using numeric value, that is, Name2
< Name7
< Name25
.
SDKs
- iOS 2.0+
- macOS 10.3+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
static var numeric: NSString.Compare Options { get }
Discussion
Numeric comparison only applies to the numerals in the string, not other characters that would have meaning in a numeric representation such as a negative sign, a comma, or a decimal point.
This option only applies to compare methods, not find.