Domanda

I want to fetch data from User table and I want to get the result ordered by first name column that contains french accents (é, à ....)

Example :

postresql return the result in this order :

ANDRIVET

ANDRÉ

ANDUEZA

but by doing this :

NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"User"];
request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"firstName" ascending:YES selector:@selector(localizedStandardCompare:)]];

I have the result in this order :

ANDRÉ

ANDRIVET

ANDUEZA
È stato utile?

Soluzione

Take a closer look...

As far as i know, E (with it's accents) comes before I. So the output from Xcode is correct. The postresql is wrong.

Also see http://en.wikipedia.org/wiki/French_alphabet - The accents are not considered separate letters. It only seems postresql misinterprets them

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top