I am working on CUDA and facing the following problem.
I have a following structure of arrays:
typedef struct Edge{
int *from, *to, *weight;
}
I want to sort this structure on weight array such that the corresponding “from” and “to” arrays get updated too. I thought of using Thrust library but it works only on vectors is what I understood. I can sort_by_key and get two arrays sorted but I am not able to understand how to sort three arrays? I even looked at zip_iterator but did not understand how to use it to serve my purpose. Please help
First decouple the structure into 1) keys, and 2) paddings. Then sort the keys and reorder paddings accordingly. For example, break this structure:
into:
The full code is here:
The output would be something like this: