Index: includes/display-render.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/panels/includes/display-render.inc,v
retrieving revision 1.5.2.17
diff -u -5 -p -u -p -r1.5.2.17 display-render.inc
--- includes/display-render.inc	16 Mar 2010 17:58:33 -0000	1.5.2.17
+++ includes/display-render.inc	23 May 2010 10:22:08 -0000
@@ -116,10 +116,13 @@ function panels_render_panes(&$display) 
   // some panes request to be rendered after other panes (primarily so they
   // can do the leftovers of forms).
   $panes = array();
   $later = array();
 
+  // Sort panes by their content type's weight.
+  uasort($display->content, 'panels_pane_content_type_sort');
+
   foreach ((array) $display->content as $pid => $pane) {
     $pane->shown = !empty($pane->shown); // guarantee this field exists.
     // If the user can't see this pane, do not render it.
     if (!$pane->shown || !panels_pane_access($pane, $display)) {
       continue;
@@ -312,5 +315,19 @@ function panels_display_get_title($displ
         return filter_xss_admin(ctools_context_keyword_substitute($display->title, array(), $display->context));
       }
       return NULL;
   }
 }
+
+/**
+ * Function used by uasort to sort panes by their content type's weight.
+ */
+function panels_pane_content_type_sort($a_pane, $b_pane) {
+  $a_content_type = ctools_get_content_type($a_pane->type);
+  $b_content_type = ctools_get_content_type($b_pane->type);
+  $a_weight = isset($a_content_type['weight']) ? $a_content_type['weight'] : 0;
+  $b_weight = isset($b_content_type['weight']) ? $b_content_type['weight'] : 0;
+  if ($a_weight == $b_weight) {
+    return 0;
+  }
+  return ($a_weight < $b_weight) ? -1 : 1;
+}
