0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
SQL-like sorts on your Enumerables
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

sort_by_str¶ ↑

SQL-like sorts on your Enumerables.

Getting Started¶ ↑

gem install sort_by_str
require 'sort_by_str'

Usage¶ ↑

a = Date.parse('2010-08-22')
b = Date.parse('2010-08-23)

[a,b].sort_by_str('year ASC, day DESC')
=> [b,a]

Call sort_by_str on your Enumerable with a SQL-style sort expression containing a list of fields.

A basic expression might look like like

'year, month, day'.

Optional ASC (ascending) or DESC (descending) modifiers can also be used:

'year ASC, day DESC'

send is used to extract values for comparison, so any valid method name can be used in the expression.

Author¶ ↑

Ben Koski, bkoski@nytimes.com

Copyright © 2010 The New York Times Company. See LICENSE for details.