Sort_by issue on multi criterias

HI mates

I am trying to sort an array on 2 criterias , one is just in memory
accessor, other is a record attribute :

I have the following User model :

class User < ActiveRecord::Base

name is an attribute in the table


attr_accessor :current_distance

end

In my controller, I calculate current_distance for each customer, and
set user.current_distance , but don’t save the record…

then get the following array :
all_users =>
[#<User id: 1, name: “Alan”, created_at: “2008-09-11 14:30:38”>,
#<User id: 2, name: "Bill, created_at: “2008-09-11 14:30:38”>,
#<User id: 3, name: “John”, created_at: “2008-09-11 14:30:38”>,
#<User id: 4, name: “Michael”, created_at: “2008-09-11 14:30:38”>]

that I can sort easily using
all_users.sort_by {|item| item.send ‘current_distance’ }

obviously, I cannot use all_users.sort_by {|user|
user[:current_distance] } … but I can use all_users.sort_by {|
user| user[:name] }

my issue is trying to sort_by both criteria 1st on
current_distance ASC, and 2nd on name DESC

any enlightment ?

thanks for your help

erwin

just found a piece of the problem :

all_users.sort_by{|user| [user.send(‘current_distance’), user.name]}

seems to work , but how can I set the sort order ? DESC on
current_distance et ASC on name ???

thanks