NSMutableArray*p = [[NSMutableArrayalloc]initWithObjects:@"3",@"5",@"4",@"1",nil];
for (int i = 0; i<[p count]; i++)
{
for(int j=i+1; j<[pcount];j++)
{
int a = [[p objectAtIndex:i] intValue];
// NSLog(@"a= %d",a);
int b = [[p objectAtIndex:j] intValue];
// NSLog(@"b= %d",b);
// NSLog(@"------");
if (a > b)
{
[preplaceObjectAtIndex:iwithObject:[NSStringstringWithFormat:@"%d",b]];
[preplaceObjectAtIndex:jwithObject:[NSStringstringWithFormat:@"%d",a]];
}
}
}
for (int i = 0; i<4; i++)
{
// NSLog(@"%d",[p count]);
NSLog(@"%@",[p objectAtIndex:i]);
}