 			case .Empty:
 				return [x]
 			case .Destructure(let y, let ys):
-				if cmp(x)(y) {
-					return y <| insertBy(cmp)(x)(ys)
-				}
-				return x <| l
+				return cmp(x)(y) ? y <| insertBy(cmp)(x)(ys) : x <| l
 		}
 	} }
 }

				assert(false, "Cannot find the minimum element of an empty list.")
			case .Destructure(_, _):
				return foldl1({ (let t) -> A in
					if cmp(fst(t), snd(t)) {
						return snd(t)
					}
					return fst(t)
				})(l)
		}
	}
}


/// elements, the heads of subsequent sub-arrays are compared wtih this ordering predicate until a
/// match is found.
public func >=<T : Comparable>(lhs: [T], rhs: [T]) -> Bool {
	switch (destruct(lhs), destruct(rhs)) {
		case (.Empty, .Empty):
			return true
		case (.Empty, .Destructure(_, _)):
			return false
		case (.Destructure(_, _), .Empty):
			return true
		case (.Destructure(let x, let xs), .Destructure(let y, let ys)):
			return (x == y) ? (xs >= ys) : x >= y
	}
}

/// Returns whether the two arrays are in ascending order.
public func <<T : Comparable>(lhs: [T], rhs: [T]) -> Bool {
	switch (destruct(lhs), destruct(rhs)) {
		case (.Empty, .Empty):
			return false
		case (.Empty, .Destructure(_, _)):
			return true
		case (.Destructure(_, _), .Empty):
			return false
		case (.Destructure(let x, let xs), .Destructure(let y, let ys)):
			return (x == y) ? (xs < ys) : x < y
	}
}

/// Returns whether the two arrays are in descending order.
public func ><T : Comparable>(lhs: [T], rhs: [T]) -> Bool {
	switch (destruct(lhs), destruct(rhs)) {
		case (.Empty, .Empty):
			return false
		case (.Empty, .Destructure(_, _)):
			return false
		case (.Destructure(_, _), .Empty):
			return true
		case (.Destructure(let x, let xs), .Destructure(let y, let ys)):
			return (x == y) ? (xs > ys) : x > y
	}
}

