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	15 Nov 2010 01:37:38 -0000
@@ -242,25 +242,22 @@ function tablesort_get_order($headers) {
     if (isset($header['data']) && $order == $header['data']) {
       return array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
     }
-
+  }
+  // User has not specified an order. Use first if specified; (same as sort).
+  foreach ($headers as $header) {
     if (isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) {
-      $default = array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
+      return array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
     }
   }
 
-  if (isset($default)) {
-    return $default;
+  // The first column specified is the initial 'order by' field unless otherwise specified.
+  $first = current($headers);
+  if (is_array($first)) {
+    $first += array('data' => NULL, 'field' => NULL);
+    return array('name' => $first['data'], 'sql' => $first['field']);
   }
   else {
-    // The first column specified is the initial 'order by' field unless otherwise specified.
-    $first = current($headers);
-    if (is_array($first)) {
-      $first += array('data' => NULL, 'field' => NULL);
-      return array('name' => $first['data'], 'sql' => $first['field']);
-    }
-    else {
-      return array('name' => $first, 'sql' => '');
-    }
+    return array('name' => $first, 'sql' => '');
   }
 }
 
