I simply want to sort an NSArray by the index number i.e. The order in which the values are entered into the array.
My problem is that I use this array in a uipicker, and therefore when reusing labels, end up with my values in the wrong order
My values consist of fractions. 1/4,3/8,1/2,3/4,1,1-1/14,1-3/8 etc
I want these fractions to display in the order they are entered
Must be simple, but I am having no luck
When I use sorted array localisedstandardcompare all the values get out of sequence
Any help will be appreciated
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
// Only calls the following code if component "0" has changed.
if (component == 0)
{
// Sets the global integer "component0Row" to the currently selected row of component "0"
component0Row = row;
// Loads the new values for the selector into a new array in order to reload the data.
NSDictionary *newDict = [[NSDictionary alloc]initWithDictionary:[pickerData objectForKey:[selectorKeysLetters objectAtIndex:component0Row]]];
NSArray *sortArray = [[NSArray alloc]initWithArray:[newDict allKeys]];
NSMutableArray *newValues = [[NSMutableArray alloc]initWithArray:[sortArray sortedArrayUsingSelector:@selector(compare:)]];
self.selectorKeysNumbers = newValues;
component1Row = 0;
[self.myPicker selectRow:0 inComponent:1 animated:NO];