Added sorting capabilities to CPTreeNode.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-09-14 03:47:57 -07:00
1 parent c8ed0f5436
commit d6ac69029b
2 files changed
+23

No files matched your search

+13
View File
@@ -66,4 +66,17 @@
return _childNodes[anIndex];
}
- (void)sortWithSortDescriptors:(CPArray)sortDescriptors recursively:(BOOL)shouldSortRecursively
{
[_childNodes sortUsingDescriptors:sortDescriptors];
if (!shouldSortRecursively)
return;
var count = [_childNodes count];
while (count--)
[_childNodes[count] sortWithSortDescriptors:sortDescriptors recursively:YES];
}
@end
+10
View File
@@ -59,6 +59,11 @@ CPOrderedDescending = 1;
BOOL _ascending;
}
+ (id)sortDescriptorWithKey:(CPString)aKey ascending:(BOOL)isAscending
{
return [[self alloc] initWithKey:aKey ascending:isAscending];
}
// Initializing a sort descriptor
/*!
Initializes the sort descriptor.
@@ -71,6 +76,11 @@ CPOrderedDescending = 1;
return [self initWithKey:aKey ascending:isAscending selector:@selector(compare:)];
}
+ (id)sortDescriptorWithKey:(CPString)aKey ascending:(BOOL)isAscending selector:(SEL)aSelector
{
return [[self alloc] initWithKey:aKey ascending:isAscending selector:aSelector];
}
/*!
Initializes the sort descriptor
@param aKey the property key path to sort