Skip to content

Instantly share code, notes, and snippets.

@ccaum
Created September 20, 2012 06:38
Show Gist options
  • Select an option

  • Save ccaum/3754284 to your computer and use it in GitHub Desktop.

Select an option

Save ccaum/3754284 to your computer and use it in GitHub Desktop.
Find four lowest temperature readings across all locations
---
- 10:
time: 2012-09-19 23:06:29.112718 -07:00
location: location_a
- 8:
time: 2012-09-19 23:06:19.112718 -07:00
location: location_a
- 7:
time: 2012-09-19 23:06:09.112718 -07:00
location: location_a
- 6:
time: 2012-09-19 23:05:59.112718 -07:00
location: location_a
- 11:
time: 2012-09-19 23:05:49.112718 -07:00
location: location_a
- 14:
time: 2012-09-19 23:06:29.112718 -07:00
location: location_b
- 8:
time: 2012-09-19 23:06:19.112718 -07:00
location: location_b
- 11:
time: 2012-09-19 23:06:09.112718 -07:00
location: location_b
- 8:
time: 2012-09-19 23:05:59.112718 -07:00
location: location_b
- 11:
time: 2012-09-19 23:05:49.112718 -07:00
location: location_b
#!/bin/env ruby
require 'yaml'
readings = YAML::load(IO.read('readings.yaml'))
sorted_readings = readings.sort { |a,b| a.keys.first <=> b.keys.first }
puts sorted_readings[0..4].to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment