diff --git a/includes/form.inc b/includes/form.inc
index 5cfbcfad2573ceff85e622086387761679ebce48..e4831d88ec682aba31dae1c7484e8814d07c04ad 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -2225,6 +2225,8 @@ function form_process_tableselect($element) {
       $element['#default_value'] = array();
     }
 
+    // Sort the options by their #weight if they have a #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.