diff --git a/MyController.m b/MyController.m index fa211e0..c2b57bc 100644 --- a/MyController.m +++ b/MyController.m @@ -56,6 +56,16 @@ - (void) setStartNotes: (NSArray *)newStartNotes { [_startNotes autorelease]; _startNotes = [[NSMutableArray alloc] initWithArray: newStartNotes]; + + [_startNotes sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { + if ([((StartNote*)obj1).properties[@"number"] intValue] < [((StartNote*)obj2).properties[@"number"] intValue]) { + return (NSComparisonResult)NSOrderedAscending; + } else if ([((StartNote*)obj1).properties[@"number"] intValue] > [((StartNote*)obj2).properties[@"number"] intValue]) { + return (NSComparisonResult)NSOrderedDescending; + } else { + return (NSComparisonResult)NSOrderedSame; + } + }]; } }