Ty Sayman
unread,Apr 24, 2009, 2:37:04 PM4/24/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlitepersistentobjects-user
Hi Folks,
I'm having a problem using the
sortArrayUsingSelector:withPairedMutableArrays function to sort
numbers.
After a bit of digging and lots of NSlog-ing I think that the compare:
is being done on the string value and not arithmatically. In other
words, 24 < 9 in the comparison because the first digit, 2, is less
than 9.
Is this correct?
If not, then I'm really confused. If it is, then how do you go about
sorting with an array of numbers, NSNumber(s) to get the desired
result?
Here is some of the code....not sure if it will help.
@interface OurGifts : SQLitePersistentObject {
NSNumber *displayPosition;
....and lots of other stuff
@implementation OurGifts
DECLARE_PROPERTIES(
DECLARE_PROPERTY(@"displayPosition", @"@\"NSNumber\""),
....and lots of other stuff....then...
- (void)setUpDisplayList{
NSArray *theProps = [NSArray arrayWithObjects:@"displayPosition" ,
@"giftName", nil];
NSArray *myArray = [OurGifts pairedArraysForProperties:theProps ];
NSMutableArray *ourPks = [myArray objectAtIndex:0];
NSMutableArray *ourDisplayOrder = [myArray objectAtIndex:1];
[ourDisplayOrder sortArrayUsingSelector:@selector(compare: options: )
withPairedMutableArrays:ourPks, nil];
self.displayList = ourPks;
}
At this point, displayList should be in the order of displayPosition,
but it isn't.
Should there be other function called instead of compare: ??
Thanks for your help.
On another note: THANK YOU to everyone who is contributing to SQLPO.
Ty