objective c - Sorting a MySQL Query ignoring case -


duh right off bat you'd think, "use order , column" have values of:

  1. a
  2. z
  3. b
  4. a
  5. z

and when sort them using query:

select * diaries order title asc; 

i this:

  1. a
  2. b
  3. z
  4. a
  5. z

when want this, first issue:

  1. a
  2. a
  3. b
  4. z
  5. z

i had same sorting issue else where, second issue, able fix this: temporarily putting 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 don't use comparator sort first issue bc don't want execute query sort them use array.

question: want know if there's way sort them how want, did in second issue, in sql query

objects id a , id b arrays contain other objects title, date created, description, etc. objectdiary_title returns nsstring

in sql, can use lower() or upper() functions in order by:

order lower(diaries), diaries 

Comments