internal static PhpValue FindExtreme(IEnumerable<PhpValue> array, bool maximum)
{
Debug.Assert(array != null);
PhpValue ex;
var enumerator = array.GetEnumerator();
if (enumerator.MoveNext())
{
ex = enumerator.Current;
int fact = maximum ? 1 : -1;
while (enumerator.MoveNext())
{
if (Comparison.Compare(enumerator.Current, ex) * fact > 0)
{
ex = enumerator.Current;
}
}
}
else
{
ex = PhpValue.Void;
}
enumerator.Dispose();
//
return ex;
}