SQL-like sorts on your Enumerables
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
sort_by_str.gemspec

README.rdoc

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

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