Improve the dereplication function

Add a sorting by hash code to guarantee the perfect stability of
dereplication results, even if the dataset input-order is modified.