sort and duplicate eliminate

sorting functionality and duplicate elimination