Drupal Categories Sort

I did a little tweak with this drupal site. Enabling clean URLs is very nice and enabling Path module which you can alias URL of each node is nicer. Last thing I want is the Categories block in the right navigation menu sorted alphabetically. (Default is sorted by last updated.)

After Googling for a while, I found this page "Overridding Drupal Sort order on node display". It's exactly what I want but after looking some code, I found that php code isn't the same (parameter and somethings). maybe different version of Drupal.

Finally, I decided to edit the code myself and here is the solution:

  1. Open up your editor (I'm using vi) and go to [drupalpath]/modules/taxonomy.modules
  2. Line 106 (Drupal 4.5.1) in function "taxonomy_block" is SQL Query
  3. change it from
    $result = db_query("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name");
  4. to
    $result = db_query("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY d.name");
  5. You see. I just remove "updated DESC" in "ORDER BY" so only "d.name" remains and that's I want.