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

  • Home
  • SEARCH
  • 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 1010425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:04:50+00:00 2026-05-16T09:04:50+00:00

In my rails app, I have a loop in my controller that does this:

  • 0

In my rails app, I have a loop in my controller that does this:

event_prices = []
event_dates = []
for event in @customer.events
  event_prices.push(event.total_prices)
  event_dates.push(event.event_time.strftime("%b %d, %Y at %I%p"))
end

I then use the arrays to push data into a highcharts graph. What I want to do is sort the event_dates array in order, but if I do that, I’ll lose the order of the event_prices. Right now, the event_price[1] corresponds to event_dates[1] and so on, but if I call a sort! on event_dates, it won’t sort event_prices along with it.

So how can I get it so that I sort both arrays the same way?

  • 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-05-16T09:04:51+00:00Added an answer on May 16, 2026 at 9:04 am

    How about something like:

    event_prices = []
    event_dates = []
    @customer.events.sort_by { |e| e.event_time }.each do |event|
      event_prices << event.total_prices
      event_dates << event.event_time.strftime("%b %d, %Y at %I%p")
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working within a Ruby on Rails app. I have a loop that
In my Rails app I have an @events collection of objects inherited from Event::Base
I am creating a rails app and have used this code in one of
So I have a Rails app (which in this case seems like it would
I have a Rails app with the usual application_controller, and a controller (and model)
in my Rails app have this routes.rb: devise_for :admin namespace :admin do root :to
In my rails app, i have the following function in one of my controller
Some of the users of our Ruby on Rails app have complained that page
In my Rails app I have a helper method location that gets the coordinates
I'm running a lot of ActiveRecord queries in my Rails app that have quite

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.