I have an array of days (in string format) that my program receives from user input that is somewhere between 1-7 in length. The array that is received has the day name in full text.
An example of an array I might receive is: ["Tuesday", "Monday", "Thursday"]
What I'm trying to do is sort this array from Monday to Sunday and convert the full text names to abbreviations. So my sort function for the above array would ideally return: ["M", "Tu", "Th"].
Duplicates of same day will never appear, there will never be less than 1 item and never more than 7.
Thanks.
It's crude, but this is the rough UI the user is selecting days from:

I used the selected answer but adapted it to just add it into the one place I needed it. I adapted it as follows:
-(NSArray*)array:(NSArray*)array collect:(id(^)(id object))block
{
NSMutableArray * result = [ NSMutableArray array ] ;
for( id object in array ) { [ result addObject:block( object) ] ; }
return result ;
}
-(NSArray*)arrayBySortingAndAbbreviatingDayNames:(NSArray*)arrayToSort
{
NSArray * dayNames = @[ @"Monday", @"Tuesday", @"Wednesday", @"Thursday", @"Friday", @"Saturday", @"Sunday" ] ;
NSArray * abbreviations = @[ @"M", @"Tu", @"W", @"Th", @"F", @"Sa", @"Su" ] ;
NSArray * array = [ self array:arrayToSort collect:^(NSString * dayName){
return @([ dayNames indexOfObject:dayName ]) ;
} ] ;
array = [ array sortedArrayUsingSelector:@selector( compare: ) ] ;
array = [ self array:array collect:^(NSNumber * index){
return abbreviations[ [ index integerValue ] ] ;
}];
return array ;
}