= 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.