Skip to content
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

Use stable sorting (using original position as a tie breaker) #314

Open
bhatiasiddharth opened this issue Aug 26, 2020 · 4 comments
Open

Comments

@bhatiasiddharth
Copy link

Can you please check how you sort/filter bibliography items if there 8 or more publications within same year?

Please take a look at alshedivat/al-folio#107 (comment) for more details.

@inukshuk
Copy link
Owner

Is this with grouping enabled? If not, what's your secondary sort field, after year listed in sort_by?

@bhatiasiddharth
Copy link
Author

Group_by was not enabled and there is no secondary field after year. I found a way to manually have them in the right order and not use year in sort_by. What is the default behaviour if there are multiple publications in same year.

@inukshuk
Copy link
Owner

Generally, if you don't use sort_by the order will depend on the order of your entries in the BibTeX file (entries might also be filtered, based on a query or if you used cited references only, but I don't think those would affect the order).

If you set sort_by to one or more fields then the entries will be sorted according to those fields (in the corresponding order). This uses Ruby's default array sorting algorithm which, I believe uses an in-place quicksort algorithm, but it may vary based on the exact version of Ruby and the platform. In any case, it is not guaranteed to be stable, so the order of entries where all sort fields are equal is in fact unpredictable.

Thinking about it now, we could add the original position in the file as a final tie-breaker to turn this into a stable sort.

@inukshuk inukshuk changed the title Publication order gets jumbled up when 8 or more publications in a particular year Use stable sorting (using original position as a tie breaker) Aug 28, 2020
@bhatiasiddharth
Copy link
Author

Definitely makes sense. That will be great! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants