Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8420857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:58:29+00:00 2026-06-10T02:58:29+00:00

I have the following code: @selected_authors = Author.find(:all, :conditions => [AUT_OID in (?),@selected_authors_array ])

  • 0

I have the following code:

@selected_authors = Author.find(:all, :conditions => ["AUT_OID in (?)",@selected_authors_array ])

@selected_authors_array is an array of author ids e.g: 55 75 74

Note the ids in the array are not in a particular order

When I do

<%@selected_authors.each do |author| %>
<%=author.AUT_OID  %> -- <%=author.AUT_NAME  %>
<% end %>

It displays 55, 74, 75 (it changes the order of the ids to ascending order)

I would like to keep the order of the entries in @selected_author as it is in the array ‘@selected_authors_array’.

Any help is most appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:58:31+00:00Added an answer on June 10, 2026 at 2:58 am

    It’s an issue of the underlying database.

    If you do a search/comparison on the column AUT_OID it will automatically use this index (if available) or the primary one to go though all entries.
    If the comparison returns “true” the DB will just pop the current row to the result list.
    Thus, you get an AUT_OID-ordered list if you have an index/primary on AUT_OID and do a search on it.

    I think you need to resort it manually if you really need the same order of IDs.

    Tipp: On mySQL you can see which index (and thus the order) the db is using by using the EXPLAIN syntax:

    EXPLAIN <select-statement>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my template (please note the if statement): {%
I have the following code and it gives me the text but not the
i have the following code that lists all the jpeg in the phone's gallery.
I have the following code where I want to see if a particular UIImageView
I have following code to find if row is selected, which is selected and
I have following code @using (Html.BeginForm()) { @Html.DropDownListFor(m => m.IDs, new SelectList(Model. IDs), Model.SelectedID)
I have the following code: foreach (ListItem item in check.Items) { if (item.Selected) {
I have the following code in my view: <%= form_for :command_selected, :method => get,
I have following asp.net code but it gives error when I change dropdown selected
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.