NSArray *nums = @[@2, @4, @3, @1, @2]; NSArray *sorted = [nums sortedArrayUsingSelector:@selector(compare:)];