[SPARK-3408] Fixed Limit operator so it works with sort-based shuffle.

Author: Reynold Xin <rxin@apache.org>

Closes #2281 from rxin/sql-limit-sort and squashes the following commits:

1ef7780 [Reynold Xin] [SPARK-3408] Fixed Limit operator so it works with sort-based shuffle.

(cherry picked from commit e2614038e78f4693fafedeee15b6fdf0ea1be473)
Signed-off-by: Reynold Xin <rxin@apache.org>