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 3635362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:53:40+00:00 2026-05-19T00:53:40+00:00

I’ writing a piece of code that will integrate with TripIt. In my TripIt

  • 0

I’ writing a piece of code that will integrate with TripIt. In my TripIt plans, I have an example trip with ONE item (Activity). I want to sort by date. The sort fails. When I add another Activity the sort works. I believe it’s because of when it’s a single item, it’s a hash and when it’s a collection of items, it’s an array of hashes.

Here is my sort method:

  @tripit_trip[k].sort_by { |h| h["StartDateTime"]["date"] }.each do |o|
    o["ObjectType"] = "ActivityObject"
    tmp[ o["StartDateTime"]["date"] ] = [] if tmp[ o["StartDateTime"]["date"] ].nil?
    tmp[ o["StartDateTime"]["date"] ] << o
  end

It fails on the first line.

Here is what the data looks like coming from TripIt:

 // One item
 --- 
 id: "20392856"
 trip_id: "11086745"
 is_client_traveler: "true"
 relative_url: /reservation/show/id/20392856
 display_name: Programming
 is_purchased: "true"
 StartDateTime: 
   date: "2011-01-09"
   timezone: Asia/Ulaanbaatar

This is the TripIt data when there are two items:

 // Two items

    --- 
    - id: "20631958"
      trip_id: "11086745"
      is_client_traveler: "true"
      relative_url: /reservation/show/id/20631958
      display_name: Programming 2
      is_purchased: "true"
      StartDateTime: 
        date: "2011-01-09"
        timezone: Asia/Ulaanbaatar
    - id: "20392856"
      trip_id: "11086745"
      is_client_traveler: "true"
      relative_url: /reservation/show/id/20392856
      display_name: Programming
      is_purchased: "true"
      StartDateTime: 
        date: "2011-01-09"
        timezone: Asia/Ulaanbaatar

Any insight on what I’m doing wrong would be wonderful.

Thanks!

  • 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-19T00:53:40+00:00Added an answer on May 19, 2026 at 12:53 am

    With a single item in the list, you don’t exactly need to sort. Why not just put an if in the code that skips the sort if there’s only one returned item?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.