[Enhancement] Alphabetical order ignoring non-alphanumerical characters

It would be good to have the possibility of getting the alphabetical order to ignore non-alphanumeric characters. For example, I have a list of book titles, some of them beginning with a parenthesis:

(A) citade

or with a quotation mark:

‘Först!’ :ett…

etc. Would it be possible to have the general sorting (search results, browse by, etc.) to consider valid for ordering the first character after a list of exceptions such as (A) or '?

Otherwise, can an hidden field containing the title beginning with the letter we want (e.g.: citade, or Först) be set as ‘orderable’ field? Perhaps the data-order HTML5 attribute?

Probably to do this in a performant way would mean storing the “for sorting” strings in the database so they can be indexed.

I think the most straightforward option here would be a module that does this: you configure it to work on specified properties (for most, Title would suffice), and it copies the title text for each item over into another table, removing articles or other unwanted text, and then it adds a sort option to the dropdown that will sort on those altered values.

I think I’ve described this idea elsewhere on the forums before.

Without that, there’s yes, the option of just using another metadata field to put in a “sorting key” that will sort in the order you want, and just sorting by that. All properties are actually sortable, so having one used for that purpose and just hiding it (for example with the Hide Elements module) could be a fine solution.

I think I’ll use an additional field with the title starting with the letter I want, and keep it in the DOM, hiding it via display:none, and then adding it to the sort options. I’m not sure how I can order the items by using my sorting field if that’s hidden with the Hide Properties module. Can the items be sorted by a hidden property?

All Hide Properties does is not show a property when a theme asks to list “all values” for a resource. So having a property hidden or not doesn’t affect sorting at all.

Of course a “display: none” would also work.

Ah, OK, good to know. But where do I add the rule ‘sort by hidden-field’ though? That’s what confuses me. Does each module work differently? For instance, if I want to sort a list in the Reference mode (like this one) where do I tell Omeka that I want to sort it by my hidden-field?

The trick is that this varies a little: Omeka S itself provides the sorting functionality in the backend for you which works with any property, and pretty much any browse page or module that does sorting can use that. But as to what kind of UI they present for you to pick what to sort by, that’s not always so straightforward.

For Reference specifically (this is just from me quickly scanning over Reference): it looks like you can just choose the property it should use both for sorting and display? I’m not sure it supports sorting by a different field than is displayed, but for that kind of “index” view maybe that’s what you want anyway?

Apologies if I’m being slow, I still don’t see how I can sort by any property. In the backend, for instance, I only have title, identifier, class, owner, created, and date (since I’m using Numeric Type module and date comes up as timestamp). How can I add my custom ordering field to that list?

Fro the Reference module: “it looks like you can just choose the property it should use both for sorting and display” → where do you see this option?

The sorting itself works out-of-the-box with any property, but the list in the sorter dropdown only includes those few commonly-used options you mention, plus things added by a module. You can still use any property in the query string.

As for Reference, again this is just from a quick glance, but it looked to me like Reference lets you configure which property is being listed… like a setting in the block that you’re using?

I see what you mean. If I add a property in the list Reference then that property is displayed in the list itself, even if it’s hidden via modules like Hide Property, and I think that’s expected behaviour. After all, you’re telling Omeka to display a list of those properties. It seems to me that I cannot have a Reference block listing one property and having that property ordered by another hidden property. Yes, I can edit the query, but I can only add ‘my field is equal etc. to’ and then sort it (again, only using those most common values). It would be good to have an ‘append’ option in the settings so that one can append something like ?sort_by=myprefix:myfulltitle&sort_order=desc or something like that.

Anyway, I’ll figure it out, I might be better off just customising the phtml files.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.