Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.106
diff -u -p -r1.106 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc	17 Jun 2010 13:44:45 -0000	1.106
+++ modules/taxonomy/taxonomy.admin.inc	14 Jul 2010 16:16:28 -0000
@@ -284,6 +284,7 @@ function taxonomy_overview_terms($form, 
   // An array of the terms to be displayed on this page.
   $current_page = array();
 
+  $delta = 0;
   $term_deltas = array();
   $tree = taxonomy_get_tree($vocabulary->vid);
   $term = current($tree);
@@ -292,6 +293,7 @@ function taxonomy_overview_terms($form, 
     if (empty($term)) {
       break;
     }
+    $delta++;
     // Count entries before the current page.
     if ($page && ($page * $page_increment) > $before_entries && !isset($back_step)) {
       $before_entries++;
@@ -392,6 +394,13 @@ function taxonomy_overview_terms($form, 
         // Same as above, the depth is modified by javascript, so it's a default_value.
         '#default_value' => $term->depth,
       );
+      $form[$key]['weight'] = array(
+        '#type' => 'weight',
+        '#delta' => $delta,
+        '#title_display' => 'invisible',
+        '#title' => t('Weight for added term'),
+        '#default_value' => $term->weight,
+      );
     }
     $form[$key]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'taxonomy/term/' . $term->tid . '/edit', '#options' => array('query' => drupal_get_destination()));
   }
@@ -446,8 +455,8 @@ function taxonomy_overview_terms_submit(
     return;
   }
 
-  $order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.
-  $form_state['values'] = array_merge($order, $form_state['values']); // Update our original form with the new order.
+  // Sort term order based on weight.
+  uasort($form_state['values'], 'drupal_sort_weight');
 
   $vocabulary = $form['#vocabulary'];
   $hierarchy = 0; // Update the current hierarchy type as we go.
@@ -562,6 +571,7 @@ function theme_taxonomy_overview_terms($
     drupal_add_js(array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'setting');
     drupal_add_css(drupal_get_path('module', 'taxonomy') . '/taxonomy.css');
   }
+  drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'term-weight');
 
   $errors = form_get_errors() != FALSE ? form_get_errors() : array();
   $rows = array();
@@ -577,8 +587,9 @@ function theme_taxonomy_overview_terms($
         $term['depth']['#attributes']['class'] = array('term-depth');
         $row[0] .= drupal_render($term['parent']) . drupal_render($term['tid']) . drupal_render($term['depth']);
       }
+      $term['weight']['#attributes']['class'] = array('term-weight');
+      $row[] = drupal_render($term['weight']);
       $row[] = drupal_render($term['edit']);
-
       $row = array('data' => $row);
       $rows[$key] = $row;
     }
@@ -619,7 +630,7 @@ function theme_taxonomy_overview_terms($
     $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '2'));
   }
 
-  $header = array(t('Name'), t('Operations'));
+  $header = array(t('Name'), t('Weight'), t('Operations'));
   $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'taxonomy')));
   $output .= drupal_render_children($form);
   $output .= theme('pager', array('tags' => NULL));
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.81
diff -u -p -r1.81 taxonomy.test
--- modules/taxonomy/taxonomy.test	1 Jul 2010 00:42:34 -0000	1.81
+++ modules/taxonomy/taxonomy.test	14 Jul 2010 16:16:28 -0000
@@ -574,29 +574,25 @@ class TaxonomyTermTestCase extends Taxon
     drupal_static_reset('taxonomy_get_treeterms');
     list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->vid);
 
-    // Change the order to term2, term3, term1. Emulate the reordering done by
-    // tabledrag.js by changing the page HTML source. Each term has three hidden
-    // fields, "tid:1:0[tid]", "tid:1:0[parent]", and "tid:1:0[depth]". The
-    // order of the input fields in the page is used when the form is processed.
     $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name);
-    $reorder = array(
-      'tid:' . $term1->tid . ':0' => 'tid:' . $term2->tid . ':0',
-      'tid:' . $term2->tid . ':0' => 'tid:' . $term3->tid . ':0',
-      'tid:' . $term3->tid . ':0' => 'tid:' . $term1->tid . ':0',
-      );
-    $this->drupalSetContent(strtr($this->drupalGetContent(), $reorder));
 
-    // Make term3 a child of term2, and update all hidden fields.
+    // Each term has four hidden fields, "tid:1:0[tid]", "tid:1:0[parent]",
+    // "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2,
+    // term3, term1 by setting weight property, make term3 a child of term2 by
+    // setting the parent and depth properties, and update all hidden fields.
     $edit = array(
       'tid:' . $term2->tid . ':0[tid]' => $term2->tid,
       'tid:' . $term2->tid . ':0[parent]' => 0,
       'tid:' . $term2->tid . ':0[depth]' => 0,
+      'tid:' . $term2->tid . ':0[weight]' => 0,
       'tid:' . $term3->tid . ':0[tid]' => $term3->tid,
       'tid:' . $term3->tid . ':0[parent]' => $term2->tid,
       'tid:' . $term3->tid . ':0[depth]' => 1,
+      'tid:' . $term3->tid . ':0[weight]' => 1,
       'tid:' . $term1->tid . ':0[tid]' => $term1->tid,
       'tid:' . $term1->tid . ':0[parent]' => 0,
       'tid:' . $term1->tid . ':0[depth]' => 0,
+      'tid:' . $term1->tid . ':0[weight]' => 2,
     );
     $this->drupalPost(NULL, $edit, t('Save'));
 
