Added sort and reverse functions