Chris,

I've tried to come up with a really pretty way to sort Hashes, and this is the best i've come up with (using your example):

sorted_hash = Hash.new
@users.to_csv(: ['username','password']).sort.collect {|arr| {arr[0] => arr[1]}}.each {|hsh| sorted_hash[hsh.keys.first] = hsh[hsh.keys.first]}

On Aug 30, 2006, at 12:28 AM, Chris Abad wrote:

wait, sorry.... jumped the gun on that one. i just realized why i wanted to jump through the hoops of using attributes.keys and attributes.values rather than class.column_names.

the attributes method supports the :only and :except options, so I could do something like this:

@users.to_csv(: ['username','password'])

On Aug 30, 2006, at 12:23 AM, Chris Abad wrote:

perfect... i think this is what i was looking for. thanks kevin.

_______________________________________________
Sdruby mailing list

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to