Index: includes/tablesort.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/tablesort.inc,v
retrieving revision 1.60
diff -u -p -r1.60 tablesort.inc
--- includes/tablesort.inc	28 Oct 2010 02:27:08 -0000	1.60
+++ includes/tablesort.inc	14 Nov 2010 15:42:03 -0000
@@ -80,7 +80,7 @@ class TableSort extends SelectQueryExten
     // User has not specified a sort. Use default if specified; otherwise use "asc".
     else {
       foreach ($this->header as $header) {
-        if (isset($header['sort'])) {
+        if (is_array($header) && isset($header['sort'])) {
           return $header['sort'];
         }
       }
@@ -115,11 +115,17 @@ class TableSort extends SelectQueryExten
     $order = isset($_GET['order']) ? $_GET['order'] : '';
     foreach ($this->header as $header) {
       if (isset($header['data']) && $order == $header['data']) {
-        return array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
+        return array(
+          'name' => $header['data'],
+          'sql' => isset($header['field']) ? $header['field'] : '',
+        );
       }
 
       if (isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) {
-        $default = array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
+        $default = array(
+          'name' => $header['data'],
+          'sql' => isset($header['field']) ? $header['field'] : '',
+        );
       }
     }
 
Index: includes/database/query.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/query.inc,v
retrieving revision 1.58
diff -u -p -r1.58 query.inc
--- includes/database/query.inc	26 Oct 2010 15:26:09 -0000	1.58
+++ includes/database/query.inc	14 Nov 2010 15:33:16 -0000
@@ -336,6 +336,19 @@ abstract class Query implements QueryPla
   public function &getComments() {
     return $this->comments;
   }
+
+  /**
+   * Outputs debugging information for the query.
+   *
+   * @return Query
+   *   The called object.
+   *
+   * @see debug()
+   */
+  public function debug($label = NULL, $print_r = FALSE) {
+    debug(strtr($this->connection->prefixTables($this), $this->getArguments()), $label, $print_r);
+    return $this;
+  }
 }
 
 /**
Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.101
diff -u -p -r1.101 node.admin.inc
--- modules/node/node.admin.inc	20 Oct 2010 01:31:07 -0000	1.101
+++ modules/node/node.admin.inc	14 Nov 2010 15:22:26 -0000
@@ -425,6 +425,7 @@ function node_admin_nodes() {
     ->fields('n',array('nid'))
     ->limit(50)
     ->orderByHeader($header)
+    ->debug()
     ->execute()
     ->fetchCol();
   $nodes = node_load_multiple($nids);
