Skip to content

Loading…

Sorted list #6

Merged
merged 2 commits into from

2 participants

@ecammit

The list is now alphabetically sorted. I removed the issue where selected items floated to the bottom of the list.

@ezarko ezarko merged commit 7874b27 into ezarko:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 14, 2011
  1. @ecammit

    Alphabetizes the hostfile list

    ecammit committed
  2. @ecammit
Showing with 10 additions and 1 deletion.
  1. +10 −1 Menulet.m
View
11 Menulet.m
@@ -47,6 +47,14 @@ -(void)awakeFromNib
NSLog(@"AuthorizationCreate returned %@\n", err);
}
+NSInteger substringSort(id string1, id string2, void *context)
+{
+ NSString* v1 = [string1 substringFromIndex:2];
+ NSString* v2 = [string2 substringFromIndex:2];
+ return [v1 localizedCompare:v2];
+}
+
+
-(NSArray *)status
{
NSTask *task;
@@ -69,9 +77,10 @@ -(NSArray *)status
NSRange theRange;
theRange.location = 0;
theRange.length = [lines count] - 1;
- return [lines subarrayWithRange:theRange];
+ return [[lines subarrayWithRange:theRange] sortedArrayUsingFunction:substringSort context:NULL];
}
+
-(IBAction)refresh:(id)sender
{
// remove items up to sepaerator
Something went wrong with that request. Please try again.