Subject: Re: bug#44597: 26.3; bibtex should allow reverse sorting

From: "Roland Winkler" <[email-masked]>
Date: Sat, 12 Dec 2020 10:09:37 -0600

On Mon Dec 7 2020 Lars Ingebrigtsen wrote:
> I've added Roland to the Cc's; I'm guessing he'll have some
> comments.

I am not sure the proposed patch is the best way to go.  Suppose a
BibTeX file contains just several dozen entries per year of
publication.  Then sorting by date becomes meaningful only if the
date for each entry includes not only year and month, but also the
day.  I assume that's why the proposed patch also uses a `day'
field.  But such a field is not standard for BibTeX entries, and I
am not aware of any "default" mechanisms to support it.  I guess you
maintain such a field by hand in your BibTeX database.  I am not
sure it makes sense for BibTeX mode to go in such a direction with
hard-coded hand-crafted solutions, where likely the next user wants
to do things just a little different.

How about instead a new customizable sorting scheme, where the value
of bibtex-maintain-sorted-entries is a cons pair

  (INDEX-FUN . PREDICATE)

where INDEX-FUN is a user-defined function that replaces
bibtex-entry-index, and PREDICATE is a user-defined function that
replaces the default predicate bibtex-lessp.  Then users can define
custom sorting schemes to their liking, where PREDICATE sorts the
entries based on the return values of INDEX-FUN.