Repository: internetarchive/openlibrary

Issue:
Add "sort alphabetically" to list of Works of an Author
When an (e.g. classic) author has many works, it would be nice to be able to browse them by title. Currently Works can only be sorted by date ascending/descending and number of editions.



Discussion:
Is there some reason this can't be rolled out?

Apparently the single most important reason is that there is noone at the Internet Archive to push the button.

The PR needs to be rebased so it can be merged, but that should be easy
enough to do. I've been meaning to do this for a while as I fixed up the
tests so the Travis tests pass, and the feature looks useful, but as Ben
says, finding someone who can push the button is difficult.

Giovanni from the Internet Archive did merge my test fix PR semi-recently,
and also Ben's RDF fixes that I rebased on top of the passing tests. As far
as I can tell though, those RDF changes have not yet been deployed, so
there are two buttons that need pushing. Getting code merged is something
I've managed, but getting a change released is another hurdle. I don't know
anything about the internal IA processes for releasing Openlibrary, but it
should involve more attention that just pressing a button.

I was meaning to follow this up to get a better idea of what we as
interested devs / others can do to help the process of adding to OL, but
other commitments got in the way.

Charles.

We're in the process of actively discussing how to make this process a LOT better and not just a button-press. I'm not sure what the plan is but it's definitely a thing actively being paid attention to this month (as opposed to many other months)

Great news! I'm glad things are moving forward, and am happy to help out further where I can. There was a production release last night since I posted the above, so the RDF changes I mentioned are live. I really appreciate the attention given to this as I imagine you are all busy with other projects too. If there is anything else I can do to help out, just let me know!

It would be helpful if author search results could be sorted too, by name, first published, number of works.
Consider: 
https://openlibrary.org/search/authors?q=Homer

@hornc I think this also needs the merge tag. If there is ever to be a works-merge functionality, it will be necessary to identify the list of all the work records and edition records for a single work by an author. At present that is brutally manual.
@hornc since you've done some work on this already, are you willing to be assignee? Note, being the assignee doesn't necessarily mean you are responsible for doing the work, just responsible for gathering/providing information to address the issue. From the Wiki.

>The assigned owner is not necessarily the person who will fix the issue (it is not necessarily even established, at that point, if or when the issue will be fixed at all), but rather they are the person who will do as much or as little as needed to handle the issue (asking questions, soliciting input, establishing and updating the priority, checking if it is a duplicate, etc).
>
>Once an issue is labeled State: Work In Progress, the owner is the individual doing the work, or leading/coordinating the group that is doing the work.

Also, it seems like the PR process has been streamlined since this issue was made. I'm assuming merging changes would be a lot easier now.
Side note: I tried to expose the existing `title` field for sorting, but it looks like it has too many transforms to be used for sorting. An approach like the one here seems reasonable, but would need some more investigation. Regardless adding a new field to solr requires a full reindex of our db, the process for which is kinda blocked by #3971 at the moment.
Q: Any other fields that should also be exposed at the same time?

Resolving patch:
diff --git a/openlibrary/plugins/worksearch/code.py b/openlibrary/plugins/worksearch/code.py
--- a/openlibrary/plugins/worksearch/code.py
+++ b/openlibrary/plugins/worksearch/code.py
@@ -116,6 +116,7 @@
     'editions': 'edition_count desc',
     'old': 'def(first_publish_year, 9999) asc',
     'new': 'first_publish_year desc',
+    'title': 'title_sort asc',
     'scans': 'ia_count desc',
     # Classifications
     'lcc_sort': 'lcc_sort asc',
@@ -830,7 +831,7 @@ def works_by_author(
     elif sort.startswith('new'):
         params.append(('sort', 'first_publish_year desc'))
     elif sort.startswith('title'):
-        params.append(('sort', 'title asc'))
+        params.append(('sort', 'title_sort asc'))
 
     facet_fields = [
         "author_facet",
diff --git a/openlibrary/solr/solr_types.py b/openlibrary/solr/solr_types.py
--- a/openlibrary/solr/solr_types.py
+++ b/openlibrary/solr/solr_types.py
@@ -10,6 +10,7 @@ class SolrDocument(TypedDict):
     has_fulltext: Optional[bool]
     title: Optional[str]
     title_suggest: Optional[str]
+    title_sort: Optional[str]
     subtitle: Optional[str]
     alternative_title: Optional[list[str]]
     alternative_subtitle: Optional[list[str]]
diff --git a/openlibrary/solr/types_generator.py b/openlibrary/solr/types_generator.py
--- a/openlibrary/solr/types_generator.py
+++ b/openlibrary/solr/types_generator.py
@@ -27,6 +27,7 @@ def generate():
             'text_en_splitting': 'str',
             'text_general': 'str',
             'text_international': 'str',
+            'text_title_sort': 'str',
             'boolean': 'bool',
         }
 


Test patch: