Index: modules/taxonomy.module
===================================================================
RCS file: /home/cvsroot/drupal-4.4.2/modules/taxonomy.module,v
retrieving revision 1.1
diff -u -r1.1 taxonomy.module
--- modules/taxonomy.module	23 Sep 2004 00:03:28 -0000	1.1
+++ modules/taxonomy.module	24 Sep 2004 03:33:20 -0000
@@ -378,13 +378,26 @@
 // return array of terms of a node
 function taxonomy_node_get_terms($nid, $key = "tid") {
   static $terms;
-
+	
   if (!isset($terms[$nid])) {
-    $result = db_query("SELECT t.* FROM {term_data} t, {term_node} r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name", $nid);
+	$result = db_query("SELECT t.tid, t.name, t.description, h.parent FROM term_data t,  term_node r, term_hierarchy h WHERE r.tid = t.tid AND r.nid = %d and h.tid=t.tid ORDER BY t.tid, h.parent", $nid);
     $terms[$nid] = array();
+	//fetch the objects first and put them in an array
     while ($term = db_fetch_object($result)) {
-      $terms[$nid][$term->$key] = $term;
+    	$dterms[] = $term;
     }
+	//bubble sort .. sorta :) sort the array
+	$cnt = count($dterms);
+	for ($i = 0; $i < $cnt; $i++){
+		$term_i = $dterms[$i];
+		$terms[$nid][$term_i->$key] = $term_i;
+		for ($j = $i+1; $j < $cnt; $j++ ){
+			$term_j = $dterms[$j];
+			if ($term_j->parent == $term_i->tid) { //if you're my parent
+				$terms[$nid][$term_j->$key] = $term_j;				
+			}
+		}
+	}
   }
   return $terms[$nid];
 }
