Fixed sorting bug: now puts the jth component from the unsorted list
into the kth component of the sorted list .. not vice versa!