//
//  Reproduces gnustep bug

#import <Foundation/Foundation.h>

static NSComparisonResult customCompare(NSNumber *a, NSNumber *b, void *p)
{
  if ([a intValue] < [b intValue]) {
    return NSOrderedAscending;
  } else if ([a intValue] > [b intValue]) {
    return NSOrderedDescending;
  } else {
    return NSOrderedSame;
  }
}

int main(int argc, const char *argv[])
{
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
    NSMutableArray *a = 
      [NSMutableArray arrayWithObjects:[NSNumber numberWithInt:0], [NSNumber numberWithInt:1], [NSNumber numberWithInt:5], [NSNumber numberWithInt:2], nil];
    [a sortUsingFunction:customCompare context:0];
    NSLog(@"Sorted array contents:");
    for (NSNumber *n in a) {
      NSLog(@"%@", n);
    }

    [pool release];
    return 0;
}
