Apply ordering. #3275.

.second and .last are non-deterministic unless a query is ordered.