func (rs Ranges) Sort() Ranges {
	sort.Sort(rs)
	return rs
}
Sort sorts the receiving Ranges and returns the result; convenience
package mesos
import (
	"sort"
)
type Ranges []Value_Range
func NewRanges(ns ...uint64) Ranges {
	xs := append(uint64s{}, ns...)
	sort.Sort(xs)
	rs := make(Ranges, len(xs))
	for i := range xs {
		rs[i].Begin, rs[i].End = xs[i], xs[i]
	}
	return rs.Squash()
}
func NewPortRanges(o *Offer) Ranges {
	if o == nil {
		return Ranges{}
	}
	var (
		r     Resource
		found bool
	)
	for i := range o.Resources {
		if o.Resources[i].GetName() == "ports" {
			r = o.Resources[i]
			found = true
			break
		}
	}
	if !found {
		return Ranges{}
	}
	offered := r.GetRanges().GetRange()
	rs := make(Ranges, len(offered))
	for i, r := range offered {
		if lo, hi := r.GetBegin(), r.GetEnd(); lo <= hi {
			rs[i].Begin, rs[i].End = lo, hi
		} else {
			rs[i].Begin, rs[i].End = hi, lo
		}
	}
	return rs.Sort().Squash()
}
func (rs Ranges) Len() int      { return len(rs) }
func (rs Ranges) Swap(i, j int) { rs[i], rs[j] = rs[j], rs[i] }
func (rs Ranges) Less(i, j int) bool {
	return rs[i].Begin < rs[j].Begin || (rs[i].Begin == rs[j].Begin && rs[i].End < rs[j].End)
}
func (rs Ranges) Size() uint64 {
	var sz uint64
	for i := range rs {
		sz += 1 + (rs[i].End - rs[i].Begin)
	}
	return sz
}