changed sort to nsort which destructively sorts and added sort which non-destructively sorts
test