1. Review C Array sorting
int a[6] = {1,4,3,5,6,2};
Choose
for (int i =0; i<6-1; i++) {
for (int j = i+1; j<6;j++) {
if (A[i]>a[j]) {
int tmp = A[i];
A[i] = A[j];
A[J] = tmp;
}
}
}
for (int i=0;i<6;i++) {
printf ("a[%d] =%d\n", i,a[i]);
}
Nsarray sort
Nsarray * array = @[@ "1", @ "4", @ "5", @ "7", @ "2", @ "9"];
The current put-back value is an array, which is provided by default, and is not frequently used in compliance with limitations of small scale
[Array sortedarrayusingselector: @selector (compare:)];
[Array sortedarraywithoptions:<# (nssortoptions) #> Usingcomparator:<#^nscomparisonresult (ID obj1, id obj2 ) Cmptr#>]
[Array sortedarrayusingfunction:<# (Nsinteger (*) (__strong ID, __strong id, void *)) #> context:<# (void *) # ;]
Nsmutablearray * arr2 = [[Nsmutablearray Alloc]initwitharray:array];
for (int i = 0; i<[arr2 count]-1; i++) {
for (int j = i+1; j<[arr2 count]; j + +) {
if ([Arr2[i] intvalue]) > ([Arr2[j] intvalue]) {
NSString * str = arr2[i];
Arr2[i] = Arr2[j];
ARR2[J] = str;
}
}
}
NSLog (@ "%@", arr2);
IOSOC/C array of immutable variables