私はたくさん検索しましたが、アレイA / Cを要件に合わせて2つ並べ替えることができませんでした
私はこのコードを使用しました:
[array1 sortArrayUsingSelector:@selector(caseInsensitiveCompare:) withPairedMutableArrays:arrForName, arrForAddress, nil];
ありがとう
私はたくさん検索しましたが、アレイA / Cを要件に合わせて2つ並べ替えることができませんでした
私はこのコードを使用しました:
[array1 sortArrayUsingSelector:@selector(caseInsensitiveCompare:) withPairedMutableArrays:arrForName, arrForAddress, nil];
ありがとう
NSArray Class Reference には- sortArrayUsingSelector:withPairedMutableArrays:
メソッドがありません。NSMutableArray クラス リファレンスにもありません。必要に応じて、メソッドのような他のメソッドを使用できますNSMutableArray
sortUsingSelector:
。
2 つの配列をキーと値としてディクショナリに入れます
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:arrForAddress forKeys:arrForName];
// Sort the first array
NSArray *sortedFirstArray = [[dictionary allKeys] sortedArrayUsingSelector:@selector(compare:)];
// Sort the second array based on the sorted first array
arrForAddress=[[NSMutableArray alloc]init ];
NSArray *sortedSecondArray = [dictionary objectsForKeys:sortedFirstArray notFoundMarker:[NSNull null]];
// arrForAddress = [dictionary objectsForKeys:sortedFirstArray notFoundMarker:[NSNull null]];
[arrForAddress addObjectsFromArray:sortedSecondArray];
NSLog(@"arrangesort......%@",arrForAddress);