Changes for sort method, SEGFAULT in place, need some changes