Using Views Tagadelic I have a problem with the sort order of tags when it comes to special characters. I set "Taxonomy: Term Name" as sort criteria in views which shows my tags in an alphabetical order. But: When there are tags starting with a special character (like ä, ö, ü, ß; talking about a website in german), those are listed before all the others. Example:

Categories: birnen, ananas, äpfel, obst, überfluss, absinth
Sort order (should be): absinth, äpfel, ananas, birnen, obst, überfluss
Sort order (is): äpfel, überfluss, absinth, ananas, birnen, obst

(I am not sure if german umlaute should be treated as the respective vowel+e (ä->ae, ö->oe, ü->ue) or just as a vowel (ä->a, ö->o, ü->u) when it comes to sorting. Both work.)

This doesn't happen when I create a view with a list of nodes ordered by title. For that reason I think it's a Views Tagadelic problem, not a Views problem.

Comments

szy’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

It happens to me too, in Polish characters. Any fix for this?

Szy.

momper’s picture

+1

pgorecki’s picture

Issue tags: +tagadelic fix

Try replacing the _tagadelic_sort_by_title in tagadelic.module to the following:

function _tagadelic_sort_by_title($a, $b) {
  static $arr;
  if (empty($arr)) {
    // set character order for your language, this one is for polish language
    $arr = array_flip(array(
      '!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@',
      'A','Ą','B','C','Ć','D','E','Ę','F','G','H','I','J','K','L','Ł','M','N','Ń','O','Ó','P','Q','R','S','Ś','T','U','V','W','X','Y','Z','Ź','Ż','[','\\',']','^','_','`',
      'a','ą','b','c','ć','d','e','ę','f','g','h','i','j','k','l','ł','m','n','ń','o','ó','p','q','r','s','ś','t','u','v','w','x','y','z','ź','ż','{','|','}'
    ));
  }
  
  $len1 = mb_strlen($a->name);
  $len2 = mb_strlen($b->name);
  
  for ($i=0;$i<min($len1,$len2);$i++) {
    $c1 = $arr[mb_substr($a->name,$i,1)];
    $c2 = $arr[mb_substr($b->name,$i,1)];

    if ($c1<$c2) return -1;
    if ($c1>$c2) return 1;    
  }
  
  if ($len1<$len2) return -1;
  if ($len1>$len2) return -1;
  return 0;
}
szy’s picture

Works like a charm :]

Dzięki :)

Szy.

yan’s picture

The following seems to work with german language:

function _tagadelic_sort_by_title($a, $b) {
  static $arr;
  if (empty($arr)) {
    // set character order for your language, this one is for german language
    $arr = array_flip(array(
      '!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@',
      'A','Ä','B','C','D','E','F','G','H','I','J','K','L','M','N','O','Ö','P','Q','R','S','T','U','Ü','V','W','X','Y','Z','[','\\',']','^','_','`',
      'a','ä','b','c','d','e','f','g','h','i','j','k','l','m','n','o','ö','p','q','r','s','ß','t','u','ü','v','w','x','y','z','{','|','}'
    ));
  }
 
  $len1 = mb_strlen($a->name);
  $len2 = mb_strlen($b->name);
 
  for ($i=0;$i<min($len1,$len2);$i++) {
    $c1 = $arr[mb_substr($a->name,$i,1)];
    $c2 = $arr[mb_substr($b->name,$i,1)];

    if ($c1<$c2) return -1;
    if ($c1>$c2) return 1;   
  }
 
  if ($len1<$len2) return -1;
  if ($len1>$len2) return -1;
  return 0;
}

But this looks like a very specific (language based) way to me. Does anybody have an idea how to solve this more generally?

kecinzer’s picture

I have the same problem in czech language.
I mean, that to this can be applied ascii file from pathauto module.

Bèr Kessels’s picture

Status: Active » Closed (duplicate)
szy’s picture

Status: Closed (duplicate) » Active

@Ber, 'closed'?

Where exactly have you found a solution (patch ready for apply,
dev release) for this issue?

Szy.

smitty’s picture

I've got the same problem here.

Replacing the _tagadelic_sort_by_title in tagadelic.module to the code in #5 solves the sorting-problem.

BUT: Now I get lots of errors:

Notice: Undefined index: in _tagadelic_sort_by_title() (Zeile 315 von mydomain\sites\all\modules\tagadelic\tagadelic.module).
Notice: Undefined index: in _tagadelic_sort_by_title() (Zeile 316 von mydomain\sites\all\modules\tagadelic\tagadelic.module).

Line 315/316 are:
$c1 = $arr[mb_substr($a->name,$i,1)];
$c2 = $arr[mb_substr($b->name,$i,1)];

Does anybody know how I can avoid these errors?

Bèr Kessels’s picture

Status: Active » Closed (duplicate)

https://github.com/berkes/tagadelic/issues/20

Please. Do not re-open. Tickets are moved to github and managed there. Here is why.