Index: cck.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/diff/cck.inc,v
retrieving revision 1.1.4.1
diff -U3 -r1.1.4.1 cck.inc
--- cck.inc	3 Feb 2007 18:47:30 -0000	1.1.4.1
+++ cck.inc	7 Dec 2007 17:58:34 -0000
@@ -53,7 +53,7 @@
           }
           break;
       }
-      $result[] = array(
+      $result[$field['widget']['label']] = array(
         'name' => $field['widget']['label'],
         'old' => $old_values,
         'new' => $new_values,
Index: diff.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/diff/diff.module,v
retrieving revision 1.8.2.8
diff -U3 -r1.8.2.8 diff.module
--- diff.module	6 Jun 2007 18:14:25 -0000	1.8.2.8
+++ diff.module	7 Dec 2007 17:58:34 -0000
@@ -345,6 +345,20 @@
 /**
  * Create the table body of the diff between $old_node and $new_node.
  * The result is a html table part enclosed in <tbody> tags.
+ *
+ * This function invokes hook_diff_alter() which can be used to perform
+ * alterations before the diff is rendered. The following example
+ * illustrates how this can be used to alter the title when
+ * "previewing changes."
+ * 
+ * function audio_diff_alter(&$old_node, &$new_node, &$diffs) {
+Ê*   global $form_values;
+ *Ê  $op = isset($form_values['op']) ? $form_values['op'] : '';
+ *
+Ê*   if ($op == t('Preview changes')) {
+Ê*  ÊÊ $diffs['title']['#new'] = array(audio_build_title($new_node));
+Ê*   }
+ * }
  */
 function _diff_table_body(&$old_node, &$new_node) {
   drupal_add_css(drupal_get_path('module', 'diff') .'/diff.css', 'module', 'all', FALSE);
@@ -360,6 +374,37 @@
   $output = '<tbody>';
   $any_visible_change = false;
   $node_diffs = module_invoke_all('diff', $old_node, $new_node);
+
+  // Need to add hook_diff_alter().
+  foreach (module_implements('diff_alter') as $module) {
+    $function = $module .'_diff_alter';
+    $function($old_node, $new_node, $node_diffs);
+  }
+
+  // We start off assuming all diff entries are in the correct order.
+  $sorted = TRUE;
+
+  // Recurse through all child elements.
+  $count = 0;
+  foreach(array_keys($node_diffs) as $key) {
+    // Assign a decimal placeholder weight to preserve original array order.
+    if (!isset($node_diffs[$key]['weight'])) {
+      $node_diffs[$key]['weight'] = $count/1000;
+    }
+    else {
+      // If one of the child elements has a weight then we will need to sort
+      // later.
+      $sorted = FALSE;
+    }
+    $count++;
+  }
+
+  // One of the children has a weight.
+  if (!$sorted) {
+    uasort($node_diffs, "_diff_sort");
+  }
+
+  // Render diffs
   foreach($node_diffs as $node_diff) {
     $diff = new Diff($node_diff['old'], $node_diff['new']);
     $formatter = new TableDiffFormatter();
@@ -381,6 +426,19 @@
 }
 
 /**
+ * Function used by uasort in _diff_table_body() to sort structured arrays
+ * by weight.
+ */
+function _diff_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;
+}
+
+/**
  * Get the entry in the revisions list after 'vid'.
  * Returns false if 'vid' is the last entry.
  */
Index: node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/diff/node.inc,v
retrieving revision 1.1
diff -U3 -r1.1 node.inc
--- node.inc	31 Jan 2007 17:45:25 -0000	1.1
+++ node.inc	7 Dec 2007 17:58:34 -0000
@@ -6,15 +6,16 @@
  */
 function node_diff(&$old_node, &$new_node) {
   $result = array();
-  $result[] = array(
+  $result['title'] = array(
     'name' => t('Title'),
     'old' => array($old_node->title),
     'new' => array($new_node->title),
     'format' => array(
       'show_header' => false,
-    )
+    ),
+    'weight' => -5,
   );
-  $result[] = array(
+  $result['body'] = array(
     'name' => t('Body'),
     'old' => explode("\n", $old_node->body),
     'new' => explode("\n", $new_node->body),
Index: taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/diff/taxonomy.inc,v
retrieving revision 1.1
diff -U3 -r1.1 taxonomy.inc
--- taxonomy.inc	31 Jan 2007 17:45:25 -0000	1.1
+++ taxonomy.inc	7 Dec 2007 17:58:34 -0000
@@ -24,7 +24,7 @@
       $new_taxonomy[] = $term->name;
     }
   }
-  $result[] = array(
+  $result['taxonomy'] = array(
     'name' => t('Taxonomy'),
     'old' => $old_taxonomy,
     'new' => $new_taxonomy,
Index: upload.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/diff/upload.inc,v
retrieving revision 1.1.4.1
diff -U3 -r1.1.4.1 upload.inc
--- upload.inc	6 Jun 2007 18:14:25 -0000	1.1.4.1
+++ upload.inc	7 Dec 2007 17:58:34 -0000
@@ -18,7 +18,7 @@
       $new_files[] = $file->filename;
     }
   }
-  $result[] = array(
+  $result['attachments'] = array(
     'name' => t('Attachments'),
     'old' => $old_files,
     'new' => $new_files,
