Mike Slinn
Mike Slinn


Published 2020-10-03. Last modified 2023-05-18.
Time to read: 1 minutes.

This page is part of the jekyll_plugins collection, categorized under Jekyll.

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.


Add the following highlighted line to your Jekyll project's Gemfile, within the jekyll_plugins group:

group :jekyll_plugins do 
  gem 'jekyll_sort_natural'

And then execute:

$ bundle

Usage Example

Case-insensitive category sort
{% 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.

GitHub Project and RubyGem

More information is available about this plugin from its GitHub project at github.com/mslinn/jekyll_sort_natural. This plugin is provided as a Ruby gem at rubygems.org/gems/jekyll_sort_natural.


This plugin contains code modified from tkrotoff.