Histogram sort with sampling