fix bug in selectionsort where input array gets emptied after sort