views:

675

answers:

1

I'm trying to create a compare function like the example on the apple site:

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray%5FClass/NSArray.html#//apple%5Fref/occ/instm/NSArray/sortedArrayUsingFunction%3Acontext%3A

The example is not objective-c. Does anyone know how I can convert the example:

NSInteger intSort(id num1, id num2, void *context)
{
int v1 = [num1 intValue];
int v2 = [num2 intValue];
if (v1 < v2)
    return NSOrderedAscending;
else if (v1 > v2)
    return NSOrderedDescending;
else
    return NSOrderedSame;
}

to a function I can call with sortedArrayUsingFunction.

Thanks!

+2  A: 

That function works with sortedArrayUsingFunction, see my updated answer on your other question for how to call it

slf