-
Hi, Is there any way to use cub for multi-keyword sorting? Or is there any plan to support multi-keyword sorting? Pseudo code: // Declare, allocate, and initialize device-accessible pointers for sorting data
int num_items; // e.g., 7
int *d_keys_in1; // e.g., [8, 8, 7, 5, 3, 3, 9]
int *d_keys_in2; // e.g., [1, 2, 0, 0, 4, 3, 0]
int *d_keys_out; // e.g., [ ... ]
int *d_values_in; // e.g., [0, 1, 2, 3, 4, 5, 6]
int *d_values_out; // e.g., [ ... ]
// Run sorting operation
cub::DeviceRadixSort::SortPairs(d_temp_storage, temp_storage_bytes,
d_keys_in1, d_keys_in2, d_keys_out, d_values_in, d_values_out, num_items);
// d_keys_out <-- [3, 3, 5, 7, 8, 8, 9]
// d_values_out <-- [5, 4, 3, 2, 0, 1, 6] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
You can zip the two keys together using |
Beta Was this translation helpful? Give feedback.
-
@pauleonix beat me to it 🚀
This is indeed the preferred way of sorting composed sort keys. I've put together a code sample on how you can use the decomposer object to implement your use case. Let me know if you have any questions about it. Link to code sample: Code Sample
|
Beta Was this translation helpful? Give feedback.
@pauleonix beat me to it 🚀
This is indeed the preferred way of sorting composed sort keys.
I've put together a code sample on how you can use the decomposer object to implement your use case. Let me know if you have any questions about it.
Link to code sample:
https://godbolt.org/z/5dGexEhYo
Code Sample