cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

lufi
Journeyman III

Sort an array of structures

Hi,
I'm using this sample code from AMD OpenCL SDK and I need help with this:

I don't want to sort only one dimensional array, but the array of struct(int, string, string), example:

before sort:
2 John Terry
1 Pavel Nedved
3 Jaromir Jagr

sorted by first column:
1 Pavel Nedved
2 John Terry
3 Jaromir Jagr

Many thanks in advance Lubos.

0 Likes
1 Reply
binying
Challenger

If you want to use the SDK sampele to save some time, you can convert the structure to a one dimensional array and sort the array.

2 John Terry      ->   2*1000000 + 10 *100 + 20 (J is the 10th letter; T is the 20th letter...)

1 Pavel Nedved  ->   1*1000000 + 16 *100 + 14

3 Jaromir Jagr  ...

0 Likes