Sort slides in-place.

Also add sort_by_rank to make this sort optional.