[cpp] add simple sorting