Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

nytimes/sort_by_str

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

SQL-like sorts on your Enumerables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages