I want to sort a list of integer values, but before sorting them I should divide them to a number N. So I will have some duplicate keys, and I will use this duplication for stable_sort in the list.
My question is that, which is better either to divide all the values and store the divided values in a list and then perform the sort, or using a transform_iterator? Is using transform_iterator changes the sort algorithm from radix_sort to merge_sort, because they have huge time difference.
For example:
//already sorted according to another parameter
thrust::device_vector<int> myvalues...
//we want to group them..
thrust::transform(myvalues.begin(), myvalues.end(), groups.begin(), divide_by_n(N));
thrust::stable_sort_by_key(groups.begin(), groups.end(), myvalues.begin();
or
first = thrust::make_transform_iterator(myvalues.begin(), divide_by_n(N));
last = thrust::make_transform_iterator(myvalues.end(), divide_by_n(N));
thrust::stable_sort_by_key(first, last, myvalues.begin());
Thanks
According from this post(comments from @JaredHoberock), the second one does not work. How to sort with less precision on keys with Thrust library