Reputation: 479
the Index of a tableview search bar is showing upper and lower case letters separated the Upper alphabet first and the lower alphabet starting after, how can I stop this? I need a Index with no case sensitive. The database has upper and lower case words.
// Get the section titles from the dictionary's keys and sort them in ascending order sectionTitles = String sectionTitles = sectionTitles.sort({ $0 < $1 }) }
Upvotes: 0
Views: 61
Reputation: 73186
For sorting of the dictionary keys, you can append .lowercaseString
to each key. This will make no difference between upper or lower case letters in your keys, as all keys---in the comparison for sorting---will be lower case strings.
func createCockpitDict(){
// ...
sectionTitles = [String](cockpitDict.keys)
sectionTitles = sectionTitles.sort({ $0.lowercaseString < $1.lowercaseString })
}
Upvotes: 1