1 Reply Latest reply on Nov 26, 2012 9:54 AM by binying

    Sort an array of structures

    lufi

      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.

        • Re: Sort an array of structures
          binying

          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  ...