Index: faq/faq.module
===================================================================
--- faq/faq.module	(revision 3646)
+++ faq/faq.module	(working copy)
@@ -475,7 +475,6 @@
       ->condition('n.type', 'faq')
       ->condition('n.status', 1)
       ->condition(db_or()->condition("$weight_alias.tid", 0)->isNull("$weight_alias.tid"))
-      ->orderBy('weight', 'DESC')
       ->orderBy('n.sticky', 'DESC');
 
     if ($default_sorting == 'DESC') {
@@ -487,9 +486,9 @@
       $query->orderBy('n.created');
     }
 
-    $query->addExpression('if((w.weight IS NULL), :default_weight, w.weight)', 'weight', array(':default_weight' => $default_weight));
+    $query->addExpression('COALESCE(w.weight, :default_weight)', 'effective_weight', array(':default_weight' => $default_weight));
+    $query->orderBy('effective_weight', 'DESC');
 
-
     // Only need the nid column.
     $nids = $query->execute()->fetchCol();
     $data = node_load_multiple($nids);
@@ -624,7 +623,6 @@
     ->condition('n.type', 'faq')
     ->condition('n.status', 1)
     ->condition("{$ti_alias}.tid", $term->tid)
-    ->orderBy('weight', 'DESC')
     ->orderBy('n.sticky', 'DESC')
     ->addTag('node_access');
 
@@ -637,8 +635,9 @@
     $query->orderBy('n.created');
   }
 
-  $query->addExpression('if((w.weight IS NULL), :default_weight, w.weight)', 'weight', array(':default_weight' => $default_weight));
-
+  $query->addExpression('COALESCE(w.weight, :default_weight)', 'effective_weight', array(':default_weight' => $default_weight));
+  $query->orderBy('effective_weight', 'DESC');
+	
   // We only want the first column, which is nid, so that we can load all
   // related nodes.
   $nids = $query->execute()->fetchCol();
@@ -1102,7 +1101,6 @@
     ->condition('n.type', 'faq')
     ->condition('n.status', 1)
     ->condition(db_or()->condition("{$w_alias}.tid", 0)->isNull("{$w_alias}.tid"))
-    ->orderBy('weight')
     ->orderBy('n.sticky', 'DESC')
     ->addTag('node_access');
 
@@ -1115,8 +1113,8 @@
     $query->orderBy('n.created');
   }
 
-  $query->addExpression('if((w.weight IS NULL), :default_weight, w.weight)', 'weight', array(':default_weight' => $default_weight));
-  $query->orderBy('weight');
+  $query->addExpression('COALESCE(w.weight, :default_weight)', 'effective_weight', array(':default_weight' => $default_weight));
+  $query->orderBy('effective_weight');
 
   // We only want the first column, which is nid, so that we can load all
   // related nodes.
@@ -1400,7 +1398,6 @@
         ->condition('n.type', 'faq')
         ->condition('n.status', 1)
         ->condition("{$ti_alias}.tid", $child_term->tid)
-        ->orderBy('weight')
         ->orderBy('n.sticky', 'DESC')
         ->addTag('node_access');
 
@@ -1413,8 +1410,8 @@
         $query->orderBy('n.created');
       }
 
-      $query->addExpression('if((w.weight IS NULL), :default_weight, w.weight)', 'weight', array(':default_weight' => $default_weight));
-      $query->orderBy('weight');
+      $query->addExpression('COALESCE(w.weight, :default_weight)', 'effective_weight', array(':default_weight' => $default_weight));
+      $query->orderBy('effective_weight');
 
       // We only want the first column, which is nid, so that we can load all
       // related nodes.
