Skip to content

Instantly share code, notes, and snippets.

@don-durrance
Created September 15, 2016 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save don-durrance/b6e14bf86bdc7dc9f8966ea94e3b8d55 to your computer and use it in GitHub Desktop.
Save don-durrance/b6e14bf86bdc7dc9f8966ea94e3b8d55 to your computer and use it in GitHub Desktop.
{"Sale Date"=>"7/24/2016",
"Item price"=>"$30.00",},
{"Sale Date"=>"7/24/2016",
"Item price"=>"$60.00",},
{"Sale Date"=>"7/25/2016",
"Item price"=>"$10.00",},
{"Sale Date"=>"7/25/2016",
"Item price"=>"$20.00",},
etc...
{"Sale Date"=>"7/24/2016",
"Client"=>"Amajor, Caitlin",
"Sale ID"=>"58198",
"Item name"=>"$30 for 30 (NEW STUDENTS ONLY)",
"Sales Notes"=>nil,
"Location"=>"Online Store",
"Notes"=>nil,
"Color"=>"---",
"Size"=>"---",
"Item price"=>"$30.00",
"Quantity"=>"1",
"Subtotal"=>"$30.00",
"Discount %"=>"0.00",
"Discount amount"=>"$0.00",
"Tax"=>"$0.00",
"Item Total"=>"$30.00",
"Total Paid w/ Payment Method"=>"$30.00",
"Payment Method"=>"Credit card (Visa/MC-Keyed)"},
def sort_by(key)
self.hash.sort_by{ |row| row[key] }
end
def sort_by_date_and(key)
hash = self.hash.sort_by{ |row| row["Sale Date"] }
# sorted by Sale Date, what now?
# Want to sort by date, and then within each date sort by another key such as "Item price"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment