RankSEG: A Consistent Ranking-based Framework for Segmentation