Version 1.2: Added sort and aid function sortHelper, accompanied by shift function