Merging API data and ActiveRecord data for display in the view...

Hi there,

I’m trying to merge JSON results from an API call in with ActiveRecord
results for a blended display in a view. I’d like to be able to merge
the two result sets based on 'created_at' which is is common in both
the ActiveRecord results and the JSON results from the API. Created_at
is the only common element between the two data sets.

Here’s what I have in my controller for retrieving the data:

@diary = current_user.diary(params[:page])
start_date = @diary.first.created_at.to_s(:date_query)
end_date = @diary.last.created_at.to_s(:date_query)
@tweets = JSON.parse(Net::HTTP.get(URI.parse("http://{current_user.twitter_name}
@tweets = @tweets['results']
@blend = @diary.entries.concat(@tweets) # tried something like this...
Not sure this is the best way to go

What’s the best way to merge these two results and sort them by
'created_at for display given that
they are so different? Should I do this in the controller or the
view? Any guidance or example would be greatly