protected final function visitOrderings(O\MethodCallExpression $expression)
{
$orderings = [];
$count = 0;
while ($expression instanceof O\MethodCallExpression && stripos($methodName = $this->getMethodName($expression), 'thenBy') === 0) {
$orderings[] = $this->visitOrdering($count, $expression);
$expression = $expression->getValue();
$count++;
}
if (stripos($this->getMethodName($expression), 'orderBy') !== 0) {
throw new PinqException('Cannot visit ordering query: must begin with an orderBy[Ascending|Descending] query method, %s given');
}
$orderings[] = $this->visitOrdering(++$count, $expression);
$this->addSegment(function ($segmentId) use($orderings) {
$this->interpretation->interpretOrderings($segmentId, array_reverse($orderings));
});
$this->visit($expression->getValue());
}