monperrus / bibtexbrowser

Beautiful publication lists with bibtex and PHP (standalone or in Wordpress)
http://www.monperrus.net/martin/bibtexbrowser/
84 stars 54 forks source link

Sorting unexpected #116

Open pucicu opened 2 years ago

pucicu commented 2 years ago

I have a bibtex file using year and month fields. I need to sort the output list by years and within the years by months. As far as I understand the documentation, I can sort it by uasort($entries, 'compare_bib_entry_by_year,compare_bib_entry_by_month'); but this does not give the expected result. The years are still unsorted. The alternatives uasort($entries, 'compare_bib_entry_by_month,compare_bib_entry_by_year'); or

uasort($entries, 'compare_bib_entry_by_year');
uasort($entries, 'compare_bib_entry_by_month');

also do not sort as expected, because the months are not in the correct order within the individual years.

How can I have a resulting list with correctly sorted time?

Thanks!

monperrus commented 2 years ago

Thanks for the bug report @pucicu.

I switched to natural order and added tests, see last commit.

usort($entries, 'compare_bib_entry_by_year') // works as expected

Could you try with the last commit on master?

pucicu commented 2 years ago

Thanks for considering this issue.

I have checked out the last version and tried. But it still does not work as I would expect.

Perhaps I should explain a bit more my needs: