Published 2020-10-03.
Last modified 2023-05-18.
Time to read: 1 minutes.
jekyll_plugins collection.
jekyll_sort_natural is a Jekyll plugin that sorts hashes using
String#casecmp,the case-insensitive version of
String#<=>.
See Add sort_natural to jekyll/filters.rb.
This plugin overrides
sort_natural,
provided by Liquid v4.
Installation
Add the following highlighted line to your Jekyll project's Gemfile,
within the jekyll_plugins group:
group :jekyll_plugins do gem 'jekyll_sort_natural' end
And then execute:
$ bundle
Usage Example
{% assign sorted_categories = site.categories | sort_natural %}
For More Information
By default,
Enumerable#sort
uses <=> for comparisons.
See Add sort_natural to jekyll/filters.rb.
This plugin overrides sort_natural provided by Liquid 4.
Acknowledgement
This plugin contains code modified from
tkrotoff.