use std::stable_sort instead