Index: tagadelic.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic/tagadelic.module,v
retrieving revision 1.47
diff -u -p -r1.47 tagadelic.module
--- tagadelic.module	13 Nov 2008 11:44:20 -0000	1.47
+++ tagadelic.module	25 Nov 2008 08:01:50 -0000
@@ -2,6 +2,11 @@
 // $Id: tagadelic.module,v 1.47 2008/11/13 11:44:20 ber Exp $
 
 /**
+ * @file
+ * Provides a class for handling tagging clouds.
+ */
+
+/**
  * Implementation of hook_help
  */
 function tagadelic_help($path, $arg) {
@@ -288,7 +293,7 @@ function tagadelic_sort_tags($tags) {
  * callback for usort, sort by count
  */
 function _tagadelic_sort_by_title($a, $b) {
-  return strnatcasecmp($a->name, $b->name);
+  return _strnatcasecmp($a->name, $b->name);
 }
 
 /**
@@ -394,3 +399,57 @@ function tagadelic_theme() {
     'tagadelic_weighted' => array('arguments' => array('terms' => NULL))
   );
 }
+
+/**
+ * Functions to replace PHP's strnatcasecmp so that it works better with
+ * international characters.
+ * Taken from http://no.php.net/manual/en/function.strnatcasecmp.php and
+ * edited to pass normal level checks from coder module.
+ */
+function _strnatcasecmp($left, $right) {
+  return _strnatcmp(strtolower($left), strtolower($right));
+}
+
+function _strnatcmp($left, $right) {
+  while ((strlen($left) > 0) && (strlen($right) > 0)) {
+    if (preg_match('/^([^0-9]*)([0-9].*)$/Us', $left, $left_match)) {
+      $left_test = $left_match[1];
+      $left = $left_match[2];
+    }
+    else {
+      $left_test = $left;
+      $left = '';
+    }
+    if (preg_match('/^([^0-9]*)([0-9].*)$/Us', $right, $right_match)) {
+      $right_test = $right_match[1];
+      $right = $right_match[2];
+    }
+    else {
+      $right_test = $right;
+      $right = '';
+    }
+    $test = strcmp($left_test, $right_test);
+    if ($test != 0) {
+      return $test;
+    }
+    if (preg_match('/^([0-9]+)([^0-9].*)?$/Us', $left, $left_match)) {
+      $left_test = intval($left_match[1]);
+      $left = $left_match[2];
+    }
+    else {
+      $left_test = 0;
+    }
+    if (preg_match('/^([0-9]+)([^0-9].*)?$/Us', $right, $right_match)) {
+      $right_test = intval($right_match[1]);
+      $right = $right_match[2];
+    }
+    else {
+      $right_test = 0;
+    }
+    $test = $left_test - $right_test;
+    if ($test != 0) {
+      return $test;
+    }
+  }
+  return strcmp($left, $right);
+}
\ No newline at end of file
