-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Years with fewer than four digits don't sort correctly #228
Comments
Looks like a bug in the sorting key extractor code - seems to be sorting year as a string. Looking into it. |
I see you have added a commit to fix this. Unfortunately, the change leads to unexpected result in some edge cases. \documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{appleby,
author = {Humphrey Appleby},
title = {A Title},
sortyear = {1980},
date = {1990},
}
@book{appleby:b,
author = {Humphrey Appleby},
title = {B Title},
sortyear = {1980},
date = {1989},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\iffalse
\DeclareSortingTemplate{nyt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
}
\sort{
\field{year}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{volume}
\literal{0}
}
}
\fi
\begin{document}
\cite{appleby:b,appleby}
\printbibliography
\end{document} As fas as I can see the problem is that |
It's not quite that. It's that the sorting data schema which is needed to generate the internal data structures needed to construct sortkey extraction and generation structures is currently not generated per-key. It is very complicated to fix this in biber as the particular field selected for a sort would need to be tracked per-entry to generate the the correct sorting data schema. Thinking about it. |
It's surprising I didn't notice this before. However, it's really difficult to solve this. Sorting needs to know the datatypes of what it is comparing and this assumes that everything in a |
People (and in fact we - as in |
True. We have to change something though as |
We could just pad the year with zeros automatically and hope for the best. This should work for positive years, not sure about negative years... |
Really don't want to do that - that's what we used to do and I switched to better sort algorithm because padding and string sort is awful with the expanded ISO date stuff we now support. It seems to me that the whole existence of |
Conceptually that would be better, I agree. But I fear it would be too big a change to render |
True but that's really an abuse of the field anyway. It's essentially a way of making the correct semantic solution of having a following |
Yeah, theoretically I agree. But practically it can happen that one needs to control the year sorting and does not have other semantic options available. Think of two |
I'm not sure adding pages would be ludicrous in those circumstances if semantically you want the paper earlier in the collection listed first as it's the pages that determine that ... |
Mhh, I really hoped I could win you over with Again, in principle I agree. But |
There is no way to make this work perfectly with hacked sortyears and the current situation is the worst I think. In general,
|
I can't think of any way that coerces |
There isn't really a generalisable way but this current |
For example, take the Nietzsche texts in the |
For I still believe that sortyear hacking is a viable way to deal with some situations. The question really is how many users would be affected and how many things we are going to break badly with this. I have no idea how many people use |
I honestly can't imagine that much would break as people using |
Maybe we should at least start a short survey on |
Ok - do you want to do that? I can prepare the changes in one commit in DEV so it can be tested and reverted. |
OK, will do. edit posted to c.t.t: https://groups.google.com/d/msg/comp.text.tex/CVSosV6gEiw/_C3sjunmAgAJ |
Can't sortyear be a float? And 1984-01 interpretated as 1984.01? (I personally never used sortyear, so simply changing it to |
Yes, there are some hacks like this that could be done but it won't help much as that's only one example of the possible formats. Also, if it was a float, year would need to be a float too and that slows down comparisons etc. |
But it would give people a workaround to salvage their hacks. If floats are too slow, we could go with a fixed number of decimal places... For the benefit of future me: The examples in |
An issue raised by the Knuth works is that |
According to the docs that already happens...
|
Ah, yes, I see I already did this ... |
By coincidence I just got a question about this with a real example. The user wanted to sort manually a number of reports and had used |
In the following MWE it seems that years are padded from the right for sorting and not from the left
results in
I know that I could use
but somehow it feels weird that I would have to enable proper integer sorting for the year...
The text was updated successfully, but these errors were encountered: