jekyll: Seemingly inconsistent sorting
- I believe this to be a bug, not a question about using Jekyll.
- I updated to the latest Jekyll (or) if on GitHub Pages to the latest
github-pages
- I ran
jekyll doctor
to check my configuration - I read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
- I am on (or have tested on) macOS 10+
- I am on (or have tested on) Debian/Ubuntu GNU/Linux
- It was another bug.
My Reproduction Steps
I can’t seem to really reproduce this.
Refer to these two websites: http://bi.tardis.ed.ac.uk/inf2 and https://betterinformatics.com/inf2
The latter URL has the correct sorting, whereas the first one (bi.tardis.ed.ac.uk) appears to sort sections (courses) randomly.
The code sorting these “sections” is handled by this line {% assign sections = site.sections | where: "year", name | sort: "title" | sort: "ordering" %}
On betterinformatics.com, it filters sections based on the year (where: "year", name
), sorts those by title (sort: "title"
) and then sorts the remaining by priority (sort: "ordering"
).
On bi.tardis.ed.ac.uk, it appears to sort by ordering, and completely garbage the sort by title, messing up the original title sorting. When removing the sort by title, the ordering doesn’t change at all, so it appears that only the last sort is being applied.
- bi.tardis.ed.ac.uk is running jekyll 3.5.1 (issue on this machine), running in docker, ruby 2.3.3p222
- betterinformatics.com is running jekyll 3.5.1 , ruby 2.3.1-2~16.04
In general, say you have a list of items
- Bob
- Alex
- Christina (ordering: -5)
- Dani
The above snippet for sorting should form:
- Christina (ordering: -5)
- Alex
- Bob
- Dani
And that sorting works fine on most platforms. However, on bi.tardis.ed.ac.uk, only the last sort is applied, mixing up the rest of the items:
- Christina (ordering: -5)
- ???
- ???
- ???
I also give all sections a default ordering value of 0. https://github.com/compsoc-edinburgh/betterinformatics/blob/master/_config.yml#L22
Both websites are running the same the same github.com/compsoc-edinburgh/betterinformatics code, but perform sorting differently…
/cc @jekyll/build
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- make the sort filter stable fixes #6275 — committed to Crunch09/jekyll by Crunch09 7 years ago
- make the sort filter stable fixes #6275 — committed to Crunch09/jekyll by Crunch09 7 years ago
- make the sort filter stable fixes #6275 — committed to Crunch09/jekyll by Crunch09 7 years ago
- make the sort filter stable fixes #6275 — committed to Crunch09/jekyll by Crunch09 7 years ago
Using a stable sorting algorithm would definitely be better, if at all possible. 👍
@qaisjp So this ticket can be closed then…?