further refactor AdaptiveSort