Duh right off the bat you'd think, "use ORDER BY and then the column" but I have values of:
- A
- Z
- B
- a
- z
And when I sort them using this query:
SELECT * FROM Diaries ORDER BY title ASC;
I then get this:
- A
- B
- Z
- a
- z
When I want to get something like this, first issue:
- A
- a
- B
- Z
- z
I had the same sorting issue else where, second issue, but I was able to fix it with this: By temporarily putting all characters in lowercase
for (NSString *key in [dicGroupedStories allKeys]) {
[dicGroupedStories setValue: [[dicGroupedStories objectForKey: key] sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
NSString *stringA = [[a objectStory_title] lowercaseString];
NSString *stringB = [[b objectStory_title] lowercaseString];
return [stringA compare: stringB];
}] forKey: key];
}
Only reason why I don't use this Comparator to sort my first issue is bc I don't want to execute my query then sort them then use the array.
Question: I want to know if there's a way to sort them how I want, like I did in my second issue, in a SQL query
objects id a and id b are arrays that contain other objects like title, date created, description, etc.
objectDiary_title
returns aNSString