mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-15 03:03:50 +00:00
Added sorting capabilities to CPTreeNode.
Reviewed by me.
This commit is contained in:
1 parent
c8ed0f5436
commit
d6ac69029b
2 files changed
+23
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user