support duplicated elements stack sort