Fix order_by on empty sequences.

It fixes #2307 but not sure if it breaks any other query.