efriedma added a comment. I haven't looked at the code changes deeply, but would it be simpler to use std::stable_sort? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81310/new/ https://reviews.llvm.org/D81310