Swift ソートの覚書「英字の小文字と英字の大文字」
単純な比較でソートすると、英字の小文字が、英字の大文字が終わった後に並ぶ。
Aa
Z
ab
下記のようにしたい。
Aa
ab
Z
コード
$0.localizedCaseInsensitiveCompare($1) == .orderedAscending
知識は力なり、知識は宝なり。
単純な比較でソートすると、英字の小文字が、英字の大文字が終わった後に並ぶ。
Aa
Z
ab
下記のようにしたい。
Aa
ab
Z
$0.localizedCaseInsensitiveCompare($1) == .orderedAscending