In the Biblio list view, "sort by" works for all options, but sorting by "Title" creates a strange sort order; with 10 entries I get "S", "E", "B", "Q", "G", "B", "P", "G", "F".
Apart from the ordering, "B" even appears twice (one title starts with "B", the second with the determiner "A").

Could this be related to #314488: Handling bibtex's {Protected} capitalization, since all the titles were imported from a BibTeX file with protected capitalization?

Comments

rjerome’s picture

Indeed it could be that (I never thought of that problem until now). The sorting is done by the database engine based on the characters in the title field, however in this case the first character may be "{" in some cases which would definitely mess it up.

As an experiment, you could modify the biblio.pages.inc file around line 150 and add the line indicated below...

  $sort_title =" CASE
                    WHEN SUBSTR(n.title,1,1)='\"'   THEN LOWER(SUBSTR(n.title,2))
                    WHEN SUBSTR(n.title,1,1)='{'   THEN LOWER(SUBSTR(n.title,2))    \\ <============ ADD THIS LINE
                    WHEN SUBSTR(n.title,1,1)='\''   THEN LOWER(SUBSTR(n.title,2))
                    WHEN SUBSTR(n.title,1,2)='A '   THEN LOWER(SUBSTR(n.title,3))
                    WHEN SUBSTR(n.title,1,3)='An '  THEN LOWER(SUBSTR(n.title,4))
                    WHEN SUBSTR(n.title,1,4)='The ' THEN LOWER(SUBSTR(n.title,5))
                    ELSE LOWER(n.title)
                 END ";
rene_w’s picture

Nope, doesn't help -- same strange search order as before.

But I noticed that this will not work in case the title starts with a brace:

    WHEN SUBSTR(n.title,1,2)='A '   THEN LOWER(SUBSTR(n.title,3))

In my case, one title starts with "{B....}" and the other "{A B....}", but they start one position later, so that's probably why I get two entries labeled "B".

Also note that the "{" doesn't have to be the first character (although in my specific example it is). Could be "A {Foo}" oder "More {Bar}"...

rjerome’s picture

I can see that this is going to be a can of worms. Do you really need "round-trip" retention of those braces (meaning are they critical for your BibTex export)? Also, it just occurred to me that they would be retained in the text when export in other formats, so that would be kind of messy :-(

rene_w’s picture

Well, given the choice, I'd rather lose sorting by title than the {Protected} capitalization (which is quite important for bibtex users). The alternative would be to keep two sets of bibliographies, the one in Drupal and the one used for working with bibtex, which seems like a lot of effort when updating them etc. I suppose other BibTeX users have the same problem. But #314488: Handling bibtex's {Protected} capitalization is only partially implemented at the moment -- the braces are filtered out for node titles and the list view but still appear in the publication block and a few other places.

Also, I just had another look at my 10 entries, and not all of them have protected titles -- if I try to filter by "first letter of title", only the ones without a brace as the first character are found (with the added patch). That might explain the strange ordering of letters.

rjerome’s picture

As a temporary work around, you can turn off the "Sort by title" tab on the biblio settings page in the "Sorting" section.

rene_w’s picture

Ok, yes that at least avoids confused users.

And at least for research papers, sorting by title is not *that* important (although entertaining -- "Hm, I should publish more papers starting with 'X'" :)

rjerome’s picture

If you really want to generate some traffic on your site, you should start them with XXX :-)

I'll see if I can polish up the edges of the that BibTex brace stuff.

Ron.

liam morland’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This version is no longer maintained. If this issue is still relevant to the Drupal 7 version, please re-open and provide details.