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?