I am using with a sortDescriptor to sort my NSFetchRequest result. I am doing this.
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Team"];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"position" ascending:YES]];
Position can be 4 values:
- Atacker
- Goalkeeper
- Winger
- Defender
At the moment it groups all the positions seperatyl. So first all the attackers, then all the goalkeepers, then all the defenders and finally all of the wingers. What I want to achieve now is to change the order of rank. The order of rank should be.
- First all the goalkeepers
- Second all the defenders
- Third all the wingers
- And lastly all the wingers
Anybody got an idea how I can do that ?
Thanks in advance!
A messy way of doing it would be to add an extra integer column representing each player type and sorting it by that instead.
EDIT: This isn’t necessarily a ‘messy’ method because it does the job however the only reason I had suggested it was messy was because you have to add in extra stuff so that you know the kind of player. Despite this, it is a reasonable method.