Interval and sort implementations