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 00:21:25 -0000
@@ -53,12 +53,12 @@
           }
           break;
       }
-      $result[] = array(
-        'name' => $field['widget']['label'],
-        'old' => $old_values,
-        'new' => $new_values,
-        'format' => array(
-          'show_header' => false,
+      $result[$field['widget']['label']] = array(
+        '#name' => $field['widget']['label'],
+        '#old' => $old_values,
+        '#new' => $new_values,
+        '#format' => array(
+          '#show_header' => false,
         ),
       );
     }
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 00:21:26 -0000
@@ -360,15 +360,46 @@
   $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 form elements are in the correct order.
+  $node_diffs['#sorted'] = TRUE;
+
+  // Recurse through all child elements.
+  $count = 0;
+  foreach(element_children($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.
+      unset($node_diffs['#sorted']);
+    }
+    $count++;
+  }
+
+  // One of the children has a #weight.
+  if (!isset($node_diffs['#sorted'])) {
+    uasort($node_diffs, "_element_sort");
+  }
+
+  // Render diffs
   foreach($node_diffs as $node_diff) {
-    $diff = new Diff($node_diff['old'], $node_diff['new']);
+    $diff = new Diff($node_diff['#old'], $node_diff['#new']);
     $formatter = new TableDiffFormatter();
-    if (isset($node_diff['format'])) {
-      $formatter->show_header = $node_diff['format']['show_header'];
+    if (isset($node_diff['#format'])) {
+      $formatter->show_header = $node_diff['#format']['#show_header'];
     }
     $formatter_output = $formatter->format($diff);
     if ($formatter_output) {
-      $output .= '<tr><td colspan="4" class="diff-section-title">'. t('Changes to %name', array('%name' => $node_diff['name'])) .'</td></tr>';
+      $output .= '<tr><td colspan="4" class="diff-section-title">'. t('Changes to !name', array('!name' => $node_diff['#name'])) .'</td></tr>';
       $output .= $formatter_output;
       $any_visible_change = true;
     }
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 00:21:26 -0000
@@ -6,18 +6,19 @@
  */
 function node_diff(&$old_node, &$new_node) {
   $result = array();
-  $result[] = array(
-    'name' => t('Title'),
-    'old' => array($old_node->title),
-    'new' => array($new_node->title),
-    'format' => array(
-      'show_header' => false,
-    )
+  $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(
-    'name' => t('Body'),
-    'old' => explode("\n", $old_node->body),
-    'new' => explode("\n", $new_node->body),
+  $result['body'] = array(
+    '#name' => t('Body'),
+    '#old' => explode("\n", $old_node->body),
+    '#new' => explode("\n", $new_node->body),
   );
   return $result;	
 }
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 00:21:26 -0000
@@ -24,10 +24,10 @@
       $new_taxonomy[] = $term->name;
     }
   }
-  $result[] = array(
-    'name' => t('Taxonomy'),
-    'old' => $old_taxonomy,
-    'new' => $new_taxonomy,
+  $result['taxonomy'] = array(
+    '#name' => t('Taxonomy'),
+    '#old' => $old_taxonomy,
+    '#new' => $new_taxonomy,
   );
   return $result;
 }
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 00:21:26 -0000
@@ -18,12 +18,12 @@
       $new_files[] = $file->filename;
     }
   }
-  $result[] = array(
-    'name' => t('Attachments'),
-    'old' => $old_files,
-    'new' => $new_files,
-    'format' => array(
-      'show_header' => false,
+  $result['attachments'] = array(
+    '#name' => t('Attachments'),
+    '#old' => $old_files,
+    '#new' => $new_files,
+    '#format' => array(
+      '#show_header' => false,
     )
   );
   return $result; 
