0.0
No release in over 3 years
Low commit activity in last 3 years
String ordering for humans.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.0.0

Runtime

~> 0.1.3
>= 0
 Project Readme

sort_authority

Natural order string comparison using natsort by Martin Pool.

Getting Started

If you're using Bundler, you can add sort_authority to your Gemfile:

gem 'sort_authority'

Or manually install the gem using:

gem install sort_authority

Usage

# bad
['9 Main Street', '10 Main Street'].sort
# => ['10 Main Street', '9 Main Street']

# good!
require 'sort_authority/ext/enumerable'
['9 Main Street', '10 Main Street'].natural_sort
# => ['9 Main Street', '10 Main Street']

Benchmarks

Comparison of sorting an array ['x1'] * 100_000 with naturalsort, naturally, natcmp, and sensible_sort.

                 user     system      total        real
sort             0.000000   0.000000   0.000000 (  0.001758)
strnatcmp.c      0.030000   0.000000   0.030000 (  0.029083)
naturalsort gem  0.060000   0.000000   0.060000 (  0.061879)
naturally gem    0.990000   0.020000   1.010000 (  1.009634)
natcmp gem       1.140000   0.010000   1.150000 (  1.141950)
sensible_sort    2.280000   0.000000   2.280000 (  2.286274)

Contributing

Fork, branch, and pull-request.