Adding the sorting method