Я просто хочу отсортировать NSArray по порядковому номеру, т.е. по порядку, в котором значения вводятся в массив.
Моя проблема в том, что я использую этот массив в uipicker, и поэтому при повторном использовании меток мои значения оказываются в неправильном порядке
Мои значения состоят из дробей. 1 / 4,3 / 8,1 / 2,3 / 4,1,1-1 / 14,1-3 / 8 и т. Д.
Я хочу, чтобы эти дроби отображались в порядке их ввода
Должно быть просто, но мне не повезло
Когда я использую отсортированный массив localisedstandardcompare, все значения выходят из последовательности
Любая помощь будет оценена
- (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];