Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.102
diff -u -p -r1.102 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc	24 Apr 2010 14:49:14 -0000	1.102
+++ modules/taxonomy/taxonomy.admin.inc	26 Apr 2010 05:49:39 -0000
@@ -394,7 +394,7 @@ function taxonomy_overview_terms($form, 
     );
     $form['actions']['reset_alphabetical'] = array(
       '#type' => 'submit',
-      '#value' => t('Reset to alphabetical')
+      '#value' => t('Sort alphabetically')
     );
     $form_state['redirect'] = array($_GET['q'], (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array()));
   }
@@ -418,7 +418,7 @@ function taxonomy_overview_terms($form, 
  * @see taxonomy_overview_terms()
  */
 function taxonomy_overview_terms_submit($form, &$form_state) {
-  if ($form_state['clicked_button']['#value'] == t('Reset to alphabetical')) {
+  if ($form_state['clicked_button']['#value'] == t('Sort alphabetically')) {
     // Execute the reset action.
     if ($form_state['values']['reset_alphabetical'] === TRUE) {
       return taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, $form_state);
@@ -627,9 +627,15 @@ function taxonomy_form_term($form, &$for
     'format' => filter_default_format(),
     'vocabulary_machine_name' => $vocabulary->machine_name,
     'tid' => NULL,
-    'weight' => 0,
+    'weight' => NULL,
   );
 
+  // Add a default weight for new terms.
+  if (!isset($edit['weight'])) {
+    $max_weight = db_query("SELECT MAX(weight) FROM {taxonomy_term_data} WHERE vid = :vid", array(':vid' => $vocabulary->vid))->fetchField();
+    $edit['weight'] = isset($max_weight) ? $max_weight + 1 : 0;
+  }
+
   // Take into account multi-step rebuilding.
   if (isset($form_state['term'])) {
     $edit = $form_state['term'] + $edit;
@@ -958,11 +964,11 @@ function taxonomy_vocabulary_confirm_res
   $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name);
   $form['reset_alphabetical'] = array('#type' => 'value', '#value' => TRUE);
   return confirm_form($form,
-                  t('Are you sure you want to reset the vocabulary %title to alphabetical order?',
+                  t('Are you sure you want to sort the vocabulary %title in alphabetical order?',
                   array('%title' => $vocabulary->name)),
                   'admin/structure/taxonomy/' . $vocabulary->machine_name,
-                  t('Resetting a vocabulary will discard all custom ordering and sort items alphabetically.'),
-                  t('Reset to alphabetical'),
+                  t('Sorting a vocabulary will discard all custom ordering and sort items alphabetically.'),
+                  t('Sort alphabetically'),
                   t('Cancel'));
 }
 
@@ -976,7 +982,7 @@ function taxonomy_vocabulary_confirm_res
     ->fields(array('weight' => 0))
     ->condition('vid', $form_state['values']['vid'])
     ->execute();
-  drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name'])));
-  watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
+  drupal_set_message(t('Sorted vocabulary %name in alphabetical order.', array('%name' => $form_state['values']['name'])));
+  watchdog('taxonomy', 'Sorted vocabulary %name in alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
   $form_state['redirect'] = 'admin/structure/taxonomy/' . $form_state['values']['machine_name'];
 }
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.77
diff -u -p -r1.77 taxonomy.test
--- modules/taxonomy/taxonomy.test	20 Apr 2010 09:48:06 -0000	1.77
+++ modules/taxonomy/taxonomy.test	26 Apr 2010 05:49:39 -0000
@@ -38,6 +38,22 @@ class TaxonomyWebTestCase extends Drupal
     taxonomy_term_save($term);
     return $term;
   }
+
+  /**
+   * Create a term through administration form.
+   */
+  function createTermThroughInterface($vocabulary, $name = NULL) {
+    $edit = array(
+      'name' => is_null($name) ? $this->randomName() : $name,
+      'description[value]' => $this->randomName(100),
+    );
+    // Explicitly set the parents field to 'root', to ensure that
+    // taxonomy_form_term_submit() handles the invalid term ID correctly.
+    $edit['parent[]'] = array(0);
+
+    // Create the term.
+    $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save'));
+  }
 }
 
 /**
@@ -509,6 +525,30 @@ class TaxonomyTermTestCase extends Taxon
   }
 
   /**
+   * Save 3 terms using the user interface and test ordering.
+   */
+  function testTermMultipleAddOrder() {
+    // Create a list of names in the reverse of alphabetic order
+    $names = array(
+      'z' . $this->randomName(),
+      'y' . $this->randomName(),
+      'x' . $this->randomName(),
+    );
+
+    $this->createTermThroughInterface($this->vocabulary, $names[0]);
+    $this->createTermThroughInterface($this->vocabulary, $names[1]);
+    $this->createTermThroughInterface($this->vocabulary, $names[2]);
+
+    // Fetch the created terms in the default order, i.e. the order in
+    // which they were created.
+    drupal_static_reset('taxonomy_get_tree');
+    drupal_static_reset('taxonomy_get_treeparent');
+    drupal_static_reset('taxonomy_get_treeterms');
+    list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->vid);
+    $this->assertEqual(array($term1->name, $term2->name, $term3->name), $names, t('Terms created through admin interface are listed in the order in which they were added.'));
+  }
+
+  /**
    * Save, edit and delete a term using the user interface.
    */
   function testTermReorder() {
@@ -557,9 +597,9 @@ class TaxonomyTermTestCase extends Taxon
     $this->assertEqual($terms[1]->parents, array($term2->tid), t('Term 3 was made a child of term 2.'));
     $this->assertEqual($terms[2]->tid, $term1->tid, t('Term 1 was moved below term 2.'));
 
-    $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name, array(), t('Reset to alphabetical'));
+    $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name, array(), t('Sort alphabetically'));
     // Submit confirmation form.
-    $this->drupalPost(NULL, array(), t('Reset to alphabetical'));
+    $this->drupalPost(NULL, array(), t('Sort alphabetically'));
 
     drupal_static_reset('taxonomy_get_tree');
     drupal_static_reset('taxonomy_get_treeparent');
