inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

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

Open bhatiasiddharth opened 3 years ago

bhatiasiddharth commented 3 years ago

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

Please take a look at https://github.com/alshedivat/al-folio/issues/107#issuecomment-680855084 for more details.

inukshuk commented 3 years ago

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

bhatiasiddharth commented 3 years ago

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 commented 3 years ago

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.

bhatiasiddharth commented 3 years ago

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