added a sorting method