add sort method and solve a problem made by a minor edit