Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1164
diff -u -p -r1.1164 common.inc
--- includes/common.inc	16 May 2010 19:21:45 -0000	1.1164
+++ includes/common.inc	16 May 2010 20:20:14 -0000
@@ -4647,7 +4647,7 @@ function drupal_cron_cleanup() {
 
 /**
  * Returns information about system object files (modules, themes, etc.).
- * 
+ *
  * This function is used to find all or some system object files (module files,
  * theme files, etc.) that exist on the site. It searches in several locations,
  * depending on what type of object you are looking for. For instance, if you
@@ -5346,9 +5346,6 @@ function drupal_render_cid_create($eleme
 function element_sort($a, $b) {
   $a_weight = (is_array($a) && isset($a['#weight'])) ? $a['#weight'] : 0;
   $b_weight = (is_array($b) && isset($b['#weight'])) ? $b['#weight'] : 0;
-  if ($a_weight == $b_weight) {
-    return 0;
-  }
   return ($a_weight < $b_weight) ? -1 : 1;
 }
 
@@ -5381,9 +5378,6 @@ function element_info($type) {
 function drupal_sort_weight($a, $b) {
   $a_weight = (is_array($a) && isset($a['weight'])) ? $a['weight'] : 0;
   $b_weight = (is_array($b) && isset($b['weight'])) ? $b['weight'] : 0;
-  if ($a_weight == $b_weight) {
-    return 0;
-  }
   return ($a_weight < $b_weight) ? -1 : 1;
 }
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.462
diff -u -p -r1.462 form.inc
--- includes/form.inc	12 May 2010 08:26:14 -0000	1.462
+++ includes/form.inc	16 May 2010 20:20:16 -0000
@@ -2573,8 +2573,9 @@ function form_process_tableselect($eleme
       $element['#default_value'] = array();
     }
 
-    // Sort the options by their #weight if they have a #weight.
+    // Sort the options by their #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.
Index: modules/field/field.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.72
diff -u -p -r1.72 field.module
--- modules/field/field.module	13 Apr 2010 15:23:02 -0000	1.72
+++ modules/field/field.module	16 May 2010 20:20:18 -0000
@@ -346,9 +346,6 @@ function _field_sort_items($field, $item
 function _field_sort_items_helper($a, $b) {
   $a_weight = (is_array($a) && isset($a['_weight'])) ? $a['_weight'] : 0;
   $b_weight = (is_array($b) && isset($b['_weight'])) ? $b['_weight'] : 0;
-  if ($a_weight == $b_weight) {
-    return 0;
-  }
   return ($a_weight < $b_weight) ? -1 : 1;
 }
 
@@ -358,9 +355,6 @@ function _field_sort_items_helper($a, $b
 function _field_sort_items_value_helper($a, $b) {
   $a_weight = (is_array($a) && isset($a['_weight']['#value'])) ? $a['_weight']['#value'] : 0;
   $b_weight = (is_array($b) && isset($b['_weight']['#value'])) ? $b['_weight']['#value'] : 0;
-  if ($a_weight == $b_weight) {
-    return 0;
-  }
   return ($a_weight < $b_weight) ? -1 : 1;
 }
 
Index: modules/field/tests/field_test.storage.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/tests/field_test.storage.inc,v
retrieving revision 1.6
diff -u -p -r1.6 field_test.storage.inc
--- modules/field/tests/field_test.storage.inc	27 Mar 2010 05:52:49 -0000	1.6
+++ modules/field/tests/field_test.storage.inc	16 May 2010 20:20:18 -0000
@@ -353,12 +353,7 @@ function field_test_field_storage_query(
  */
 function _field_test_field_storage_query_sort_helper($a, $b) {
   if ($a->type == $b->type) {
-    if ($a->entity_id == $b->entity_id) {
-      return 0;
-    }
-    else {
-      return $a->entity_id < $b->entity_id ? -1 : 1;
-    }
+    return $a->entity_id < $b->entity_id ? -1 : 1;
   }
   else {
     return $a->type < $b->type ? -1 : 1;
