Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upQuestion about sort_ConditionalMacroDates.txt #31
Comments
This one doesn't make any sense to me either.
Sorts as
as expected (with or without the title being part of the issued-date variable). It'd be great if @fbennett could chime in, but I'd currently call this as an incorrect test and suggest changing it (likely by just removing the title variable from the macro since the test is about dates) |
Ah, I remember this one. Rintze and I discussed the case in 2013, back in the BitBucket days. In the discussion Rintze also questioned the discarding of the non-date text from the macro when generating keys, and noted that doing so is an off-spec invention. As I note in the linked thread, intermixing date and string values in a single key can't be made to produce intuitive sort results. Dates are a bit special: keys for non-date variables are simple strings or numbers that can be derived directly from the variable; but date keys must generate a machine-readable sort key that takes account of the The need to express date keys in a macro can be addressed in one of two ways. One would be to assume that such macros will always contain exactly one date. The other would be to extract a date from an existing macro, and ignore everything else it contains. So that's the reasoning behind it. On a quick check of the repository (based on macro names alone), it looks like a few styles would need to be amended to add and call date-only macros if the former approach is preferred.
|
I still don't understand this, even after reading the linked discussion. It's perfectly coherent to sort first on a text field, then on a structured date field (whose fields are determined by some kind of condition). |
The test is muddled, and should be divided into two separate fixtures for clarity. The reason for boiling the macro down to the date alone is that sorting on a string concatenation of title and date can produce different results than sorting atomically on the title and then on the date. Things can get messed up if the title ends in a number. Here are three entries sorted by title, then by date:
If the same entries are sorted on a concatenation of title and date, the order comes out differently:
It's not a common case, but it does come up. Date extraction went into the processor in the early days, and I don't have the records on it to hand, but I'm pretty sure it was prompted by a user complaint about a badly sorted bibliography. |
Thanks -- the reason now makes more sense to me, though I'm still not clear what's particular about dates here: Title | 99 Red balloons Also reverses sort order when concatenated into a single string. My inclination would therefore be to have processors/tests behave according to spec and to discourage using multi-variable macros for sorting, potentially even in the specs (discourage rather than forbid because there may be cases for them, though only rarely). |
That's the best for processor simplicity. The styles listed above should be amended to assure consistent results, though. |
I'm working on that -- seems like a good idea anyway in case other processors decide(d) to ignore the test & follow the letter of the specs and it won't affect output given current citeproc-js behavior, so we don't need to coordinate timing. Will also create a PR for changing the test by removing the title from the issued-date macro. @bdarcus would you create a PR for the specs that adds something along the lines of:
(wrote this quickly, happy for edits) @jgm I think that should settle this, you can assume that the test will change -- thanks for bringing this up. |
Shouldn't we just remove this test? The file name, and purpose, of the test would change too, if we remove the macro call, and there should be other tests that cover this sorting? If not, then I'm misunderstanding the resolution, and so what the change would be. |
jgm commentedJun 25, 2020
I'm baffled by this one -- there must be something I'm not understanding.
We have
and the issued-date macro looks like this:
Note the
<text variable="title"/>
which appears before the date. So the output of this macro for the various items should be something likeAnd that should give (for an ascending sort): item-3, item-1, item-2, resulting in:
Instead, the expected result is
Here we get sorting on the date, apparently ignoring the title (and indeed, removing the line with
<text variable="title"/>
makes no difference to citeproc.js).There is no way an ascending sort that looks at titles before dates could give this result. So I'm confused! What am I missing?