Index: C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php
===================================================================
--- C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php	(revision 11110)
+++ C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/template.php	(working copy)
@@ -510,11 +510,13 @@
 
 	// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
 	$checked_categories = array();
-	for ( $i = 0; isset($categories[$i]); $i++ ) {
-		if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
-			$checked_categories[] = $categories[$i];
-			unset($categories[$i]);
-		}
+	$keys = array_keys( $categories ); 
+	
+	foreach( $keys as $k ) {
+		if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
+			$checked_categories[] = $categories[$k];
+			unset( $categories[$k] );
+		}	
 	}
 
 	// Put checked cats on top
