Terms are not sorting correctly within the vocabulary index within alphabetical display is selected. They grouped under the correct letter (all the A's show up under A) but the problem is within the order of each per-letter listing.

Comments

xano’s picture

Status: Active » Postponed (maintainer needs more info)

Could you please be more specific? A screenshot would be really helpful :)

xano’s picture

StatusFileSize
new13.81 KB
new14.84 KB

You mean like in the attached screen shots?

ianchan’s picture

StatusFileSize
new60.18 KB

I've attached an example of the problem. Thank you for your help (and for creating a very useful module).

xano’s picture

Status: Postponed (maintainer needs more info) » Active
xano’s picture

Are you sure the terms are sorted differently at Administer > Content > Taxonomy?

ianchan’s picture

Yes, I checked the terms list for the vocabulary in question and the sort is alphabetically correct.

ianchan’s picture

It looks like within each alphabetical list it is sorting top level (parent) terms into one list and then sorting child terms into a second list.

abramo’s picture

Same here - sorting is determined by vocabulary parent term hierarchy and not alphabetically.
This seems somehow inherent in Drupal taxonomy sorting - same issue is affecting the Glossary module.
It needs urgent review, as this renders the alphabetical function unusable.

xano’s picture

It doesn't really render the alphabetical view unusable, since paging works correctly (apart from a bug with really exotic characters like Chinese and Greek), but I agree this _is_ annoying.

The little time I have I mostly spend on Drupal 7, but patches or a nudge in the right direction are more than welcome!

abramo’s picture

Sorry, issue is with purely English vocabularies - no exotic characters whatsoever - nothing else than pure Latin characters.

Sorting in taxonomy is apparently determined including hierarchical considerations in hierarchical vocabularies - some kind of "key" is involved. I have sorted taxonomy vocabularies outside of any other complementary module by php, and the result is the same : terms initially sorted by starting letter and re-sorted by parent term. Of course, the parent terms are not displayed in the list, only under their own starting letter - but they are implicitly there. The same issue is alive and well with the Glossary module, another module using taxonomy vocabularies. Seems this is a more general issue connected to the way the term tree is retrieved by taxonomy.

As the sorting stands now, it does not constitute an alphabetical listing, but a messed up listing based on starting letter. You may leave it this way, of course, if you feel this is a minor consideration.

xano’s picture

The philosophy behind the alphabetical view is that all terms are paged by their first letter, which is not what this issue is about. Taxonomy itself sorts terms by weight and then by name, but for alphabetical views Vocabulary Index messes up, probably because the terms are filtered by first letter. It is definitely a bug, but since I haven't got much time due to other obligations, it may take a few weeks before this gets fixed. That is, if nobody else provides a patch.

abramo’s picture

Many thanks - time constraints are absolutely understandable, no two ways about it.
I believe that there is no sensible drupaler that does not realize that issues need their time to be resolved.

Very frequently my own frustration is that I lack the programming abilities to resolve issues and contribute the solutions back to the community. Same with this case, where if I had the knowledge I would gladly resolve this issue - both for the benefit of my own application, but also for the benefit of my fellow drupalers.

Thus, this issue will have to wait its proper turn . . . .

abramo’s picture

StatusFileSize
new146.09 KB

Printscreen of issue attached.

xano’s picture

This is a 'bug' in taxonomy_get_tree(). It should sort by weight and then by name. All terms in my demo setup have the same weight, so the result should be completely sorted by name, which is not the case. I'll see if I can write a workaround for this.

ianchan’s picture

Thank you for the follow-up on this issue.

abramo’s picture

Thanks from me too.

xano’s picture

Assigned: Unassigned » xano
Status: Active » Needs review
StatusFileSize
new1.24 KB

This patch should fix the problem for 5.x-2.x.

abramo’s picture

Many thanks for the good effort - shall test and report!

abramo’s picture

YES!!!

Excellent, Xano! - it works 100% fine for me. A real alphabetical index!
Many thanks, indeed.

xano’s picture

I guess this is RTBC then?

abramo’s picture

RTBC, as far as I am concerned!
Goed gedaan meneer :)

xano’s picture

Status: Needs review » Reviewed & tested by the community

Goed gedaan meneer :)

Mwhaha :-P

ianchan’s picture

Thanks for the patch! While the sorting works... it's only working within text of the same case. Could you change it so that it is case-insensitive?

After patching I get lists like the following:

ABC
ADC
AFC
Abc
Adc
AFC
abc
adc
afc

Shouldn't it sort as:
ABC
Abc
abc
ADC
Adc
adc

etc...

Thanks...

xano’s picture

Status: Reviewed & tested by the community » Needs work

Use strcasecmp() instead of strcmp(). I will have to check if either of these functions work with multibyte data though.

ianchan’s picture

Thanks! Changing to strcasecmp() enabled case-insensitive sorting.

xano’s picture

Status: Needs work » Fixed

Fixed and committed to 5.x-2.x-dev and 6.x-2.x-dev. Thanks a lot!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xano’s picture

Assigned: xano » Unassigned