Fix order_by on empty sequences.
Fix argument check in order_by.
Fix code style.
Merge pull request #2314 from eliangidoni/next

Fix order_by on empty sequences.