- Total Members: 220,011
- Threads: 525,382
- Posts: 976,976
-
February 4th, 2013, 08:15 PM
#1
How can I make the order of Find results match the order of Array input.
I'm performing a find on a Person model. I'm using an array of ids as the input for my Find method. The array represents the ancestry of a particular person and the order of the array is important.
I would like the find result (relation) to be in the same order as the input ancestry array. Unfortunately, the result returned is sorted in the order of the ids (ascending). Is there a way to prevent this behavior and have returned result in the order of the ancestry_array.
There's not an attribute in the model that reflects the Ancestry order so I don't see a direct way to use the order method.
ancestry_array = Array.new
ancestry_array = [23,45,89,12,90,5]
Person.find(23,45,89,12,90,5)
returned order of relation: 5,12,23,45,89,90
desired order of returned relation: 23,45,89,12,90,5
Similar Threads
-
By markw in forum Microsoft Access Help
Replies: 5
Last Post: June 3rd, 2009, 12:53 PM
-
By phoenixaz in forum ASP Development
Replies: 22
Last Post: June 13th, 2008, 10:08 PM
-
By leuvenaar in forum ASP Development
Replies: 2
Last Post: August 20th, 2006, 04:04 AM
-
By snipered in forum ASP Development
Replies: 1
Last Post: August 8th, 2005, 05:00 AM
-
By m__kruger in forum ASP Development
Replies: 2
Last Post: September 18th, 2004, 10:13 PM