--- taxonomy_dhtml.module	2007-03-03 14:07:47.000000000 +0100
+++ taxonomy_dhtml.module 2007-04-01 01:19:20.000000000 +0200
@@ -146,7 +146,8 @@
     $term = $tree[$i];
     /* restrict to a single type if given */
     $type_q = ($type ? "n.type = '$type'" : 1);
-    $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.type, u.uid, u.name FROM {term_node} r LEFT JOIN {node} n ON r.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND $type_q AND r.tid = '$term->tid' ORDER BY n.changed DESC"), 0, variable_get("taxonomy_dhtml_overview_count", 50));
+    $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.type, u.uid, u.name FROM {term_node} r LEFT JOIN {node} n ON r.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND %s AND r.tid = '%d' ORDER BY %s"), $type_q, $term->tid, variable_get('taxonomy_dhtml_sort_order', 'n.changed DESC'), 0, variable_get("taxonomy_dhtml_overview_count", 50));
+
     while ($node = db_fetch_object($result)) {
       if (module_exists('comment')) {
         $detail = t("Author: %name, comments: %num", array ("%name" => strip_tags(theme('username', $node)), "%num" => comment_num_all($node->nid)));
@@ -223,6 +224,20 @@
     '#maxlength' => 3,
     '#description' => t('The number of items to display per vocabulary in the overview page.'),
   );
+  $form['taxonomy_dhtml_sort_order'] = array(
+    '#type' => 'select',
+    '#title' => 'Sort order',
+    '#default_value' => variable_get('taxonomy_dhtml_sort_order', 'n.changed DESC'),
+    '#options' => array (
+      'n.changed DESC' => t('Time of last modification - descending'),
+      'n.changed ASC' => t('Time of last modification - ascending'),
+      'n.title DESC' => t('Title - descending'),
+      'n.title ASC' => t('Title - ascending'),
+     ),
+    '#description' => t('Choose the order of the listings.'),
+  );
+
+
   return system_settings_form($form);
 }
 
