Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

attributes_sort

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attributes_sort

  • 0.2.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= attributes_sort

This gem allows you to take a collection of any type of object and sort them using the attributes of the object.

Example:

require 'rubygems' require 'attributes_sort'

class Person

include AttributesSort

attr_accessor :firstname,:lastname,:age

def initialize(firstname="", lastname="" ,age=0) @firstname = firstname @lastname = lastname @age = age end end

people = [Person.new("joe","blow",12),Person.new("joe","blow",89),Person.new("mary","watson",32),Person.new("annie","watson",9),Person.new("bob","builder",12)]

p people.attr_sort(:sort_by=>[:lastname])

p people.attr_sort(:sort_by=>[:age])

p people.attr_sort(:sort_by=>[:lastname,:firstname,:age])

== Copyright

Copyright (c) 2009 Karmen Blake. See LICENSE for details.

FAQs

Package last updated on 25 Mar 2010

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc