Dot notation ordering

How do I order a collection returned when I've accessed it from dot
notation? For example using client.products I'd like the return to be
ordered by product.part_number. I've tried to do this Ruby side with
something like client.products.sort {|a, b| a.part_number >
b.part_number} and I get an error. Any idea how to deal with this?

Thanks,
-dustin

products = client.products.find( :all, :order => [ 'part_number' ] )

FYI Your sort code was almost right:
@products = client.products.sort {|a, b| b.part_number <=>
a.part_number}

would give you the products sorted high to low.

Hi --

Or the slightly more concise:

  @products = client.products.sort_by &:part_number

:wink:

Where is this behavior documented?

Thanks,

> @products = client.products.sort_by &:part_number

Where is this behavior documented?

Nevermind, I found it:

cat /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/symbol.rb

class Symbol
  # Turns the symbol into a simple proc, which is especially useful
for enumerations. Examples:

Excellent. Thank you all for the great answers...

-dustin

Hi --