? sites/default/files
? sites/default/private
? sites/default/settings.php
? sites/default/tmp
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.497
diff -u -p -r1.497 form.inc
--- includes/form.inc	27 Sep 2010 00:53:55 -0000	1.497
+++ includes/form.inc	29 Sep 2010 04:25:04 -0000
@@ -2957,12 +2957,12 @@ function theme_tableselect($variables) {
   $header = $element['#header'];
   if (!empty($element['#options'])) {
     // Generate a table row for each selectable item in #options.
-    foreach ($element['#options'] as $key => $value) {
+    foreach (element_children($element) as $key) {
       $row = array();
 
       $row['data'] = array();
-      if (isset($value['#attributes'])) {
-        $row += $value['#attributes'];
+      if (isset($element['#options'][$key]['#attributes'])) {
+        $row += $element['#options'][$key]['#attributes'];
       }
       // Render the checkbox / radio element.
       $row['data'][] = drupal_render($element[$key]);
@@ -3015,8 +3015,6 @@ function form_process_tableselect($eleme
       $element['#default_value'] = array();
     }
 
-    // Sort the options by their #weight if they have a #weight.
-    uasort($element['#options'], 'element_sort');
     // Create a checkbox or radio for each item in #options in such a way that
     // the value of the tableselect element behaves as if it had been of type
     // checkboxes or radios.
@@ -3047,6 +3045,9 @@ function form_process_tableselect($eleme
             '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
           );
         }
+        if (isset($element['#options'][$key]['#weight'])) {
+          $element[$key]['#weight'] = $element['#options'][$key]['#weight'];
+        }
       }
     }
   }
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.95
diff -u -p -r1.95 node.test
--- modules/node/node.test	17 Sep 2010 14:53:21 -0000	1.95
+++ modules/node/node.test	29 Sep 2010 04:25:07 -0000
@@ -1195,6 +1195,30 @@ class NodeAdminTestCase extends DrupalWe
   }
 
   /**
+   * Tests that the table sorting works on the content admin pages.
+   */
+  function testContentAdminSort() {
+    $this->drupalLogin($this->admin_user);
+    foreach (array('dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB') as $prefix) {
+      $this->drupalCreateNode(array('title' => $prefix . $this->randomName(6)));
+    }
+
+    // Compare the rendered HTML node list to a query for the nodes ordered by
+    // title to account for possible database-dependent sort order.
+    $nodes_query = db_select('node', 'n')
+      ->fields('n', array('nid'))
+      ->orderBy('title')
+      ->execute()
+      ->fetchCol();
+
+    $this->drupalGet('admin/content', array('query' => array('sort' => 'asc', 'order' => 'Title')));
+    foreach ($this->xpath('//table/tbody/tr/td/div/input/@value') as $input) {
+      $nodes_form[] = $input;
+    }
+    $this->assertEqual($nodes_query, $nodes_form, 'Nodes are sorted in the form the same as they are in the query.');
+  }
+
+  /**
    * Tests content overview with different user permissions.
    *
    * Taxonomy filters are tested separately.
