From 493fb09f6169864726be9909907fa1b84b3d0a21 Mon Sep 17 00:00:00 2001 From: bamse16 Date: Wed, 5 Aug 2009 20:40:01 +0000 Subject: Fix sortorder of tables in export multiple tables as CSV/XML accesory view --- Source/TableDump.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Source/TableDump.m b/Source/TableDump.m index ccdda6ee..3d742b6f 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -36,6 +36,7 @@ #import "SPArrayAdditions.h" #import "RegexKitLite.h" + @implementation TableDump //IBAction methods @@ -52,15 +53,26 @@ queryResult = (MCPResult *)[mySQLConnection listTables]; if ([queryResult numOfRows]) [queryResult dataSeek:0]; + NSMutableArray *unsortedTables = [NSMutableArray array]; for ( i = 0 ; i < [queryResult numOfRows] ; i++ ) { - [tables addObject:[NSMutableArray arrayWithObjects: - [NSNumber numberWithBool:YES], NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0), nil]]; + [unsortedTables addObject:[[queryResult fetchRowAsArray] objectAtIndex:0]]; } + NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)]; + NSArray *sortedTables = [unsortedTables sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]; + [desc release]; + + for ( i = 0 ; i < [sortedTables count]; i++ ) { + [tables addObject: + [NSMutableArray arrayWithObjects: + [NSNumber numberWithBool:YES], + [sortedTables objectAtIndex:i], + nil]]; + } + [exportDumpTableView reloadData]; [exportMultipleCSVTableView reloadData]; [exportMultipleXMLTableView reloadData]; - } - (IBAction)selectTables:(id)sender -- cgit v1.2.3