package main
import "fmt"
import "time"
import "sort"
func main() {
// Functions can take types?
events
= make
([]time.
Time, 2) events
[0], _
= time.
Parse("15:04", "04:30") events
[1], _
= time.
Parse("15:04", "15:12") sort.Sort(TimeSlice(events))
fmt.Println(events)
}
// WTF
type TimeSlice
[]time.
Time
// Oh, the user does do it...
func (p TimeSlice) Len() int { return len(p) }
func (p TimeSlice) Less(i, j int) bool { return p[i].Before(p[j]) }
func (p TimeSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
cGFja2FnZSBtYWluCgppbXBvcnQgImZtdCIKaW1wb3J0ICJ0aW1lIgppbXBvcnQgInNvcnQiCgpmdW5jIG1haW4oKSB7CiAgICB2YXIgZXZlbnRzIFtddGltZS5UaW1lCiAgICAgLy8gRnVuY3Rpb25zIGNhbiB0YWtlIHR5cGVzPwogICAgZXZlbnRzID0gbWFrZShbXXRpbWUuVGltZSwgMikKICAgIGV2ZW50c1swXSwgXyA9IHRpbWUuUGFyc2UoIjE1OjA0IiwgIjA0OjMwIikKICAgIGV2ZW50c1sxXSwgXyA9IHRpbWUuUGFyc2UoIjE1OjA0IiwgIjE1OjEyIikKICAgIHNvcnQuU29ydChUaW1lU2xpY2UoZXZlbnRzKSkKICAgIAogICAgZm10LlByaW50bG4oZXZlbnRzKQp9Ci8vIFdURgp0eXBlIFRpbWVTbGljZSBbXXRpbWUuVGltZQoKLy8gT2gsIHRoZSB1c2VyIGRvZXMgZG8gaXQuLi4KZnVuYyAocCBUaW1lU2xpY2UpIExlbigpIGludCAgICAgICAgICAgeyByZXR1cm4gbGVuKHApIH0KZnVuYyAocCBUaW1lU2xpY2UpIExlc3MoaSwgaiBpbnQpIGJvb2wgeyByZXR1cm4gcFtpXS5CZWZvcmUocFtqXSkgfQpmdW5jIChwIFRpbWVTbGljZSkgU3dhcChpLCBqIGludCkgICAgICB7IHBbaV0sIHBbal0gPSBwW2pdLCBwW2ldIH0=