Socket
Book a DemoInstallSign in
Socket

sort_by_field

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort_by_field

bundlerRubygems
Version
1.0.6
Version published
Maintainers
2
Created
Source

= Sort By Field

This plugin provides sorting by fields to arrays and enumerable objects. By default it is applied to arrays. It can be included in any enumerable class.

It automatically handles nil values and sorting strings without case sensitivity.

== Usage

Sort the +values+ array by the value returned by the name attribute on each entry without case sentivity:

values.sort_by_field(:name)

Sort the +values+ array by the +name+ attribute on each entry with case sentivity:

values.sort_by_field(:name, :case_sensitive => true)

Sort the +values+ array by the +name+ attribute putting nil values last instead of first:

values.sort_by_field(:name, :nil_last => true)

Sort the +values+ array by the +name+ attribute and then by the +count+ attribute:

values.sort_by_field(:name, :count)

Sort the +values+ array by the +name+ attribute in descending order:

values.sort_by_field("name desc")

Sort the +values+ array by the name of the class of each entry:

values.sort_by_field("class.name")

or

values.sort_by_field([:class, :name])

FAQs

Package last updated on 31 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts