I am trying to figure out how to sort a multidimensional data (5 dimensions) in C. I know that using a 5d array is a solution that, from reading others posts on SO about this topic many folks find, if not altogether unethical, so aesthetically repugnant so as to provoke unceasing projectile vomiting...so I apologize in advance.
Essentially I have an incoming set of data to which I must apply a series of discrete algorithms. Each algorithm has a set of variables, and I need to calculate a ranking of the efficiency of each algorithm with every permutation of the variables possible. Ultimately, I need a list sorted by the best-to-worst performing algorithm. The whole calculation is dynamic, so what works best on one incoming piece of data is unlikely to be the best performer on another...so I can't eliminate any of the variables because they are poor performers.
Here is how the data looks:
dataValue[ algo ][ lengthVar ][ durationVar ][ plasticityVar ] [ fungibilityVar]
There are:
- 35 algorithms
- 10 length variables
- 230 duration vars
- 27 plasticity vars
- 400 fungibility vars
In addition to sorting by algorithm, I would like to have the flexibility to sort on any of the 5 dimensions.
This will be run on a 12 physical/ 24 logical core machine with 192 gig (not meg) of RAM, using VS 2010 C (not C++).
I am assuming that qsort would be the most efficient sorting option. I have searched Google and SO extensively for how to do this to no avail. There are answers for 1d arrays, multidimensional arrays in PHP or C#, etc, but not for C...or at least I can't find one.
qsort
reduces the problem of sorting 5d arrays to that of comparing two 4d arrays. As long as you know how to decide with of the two algorithms is "better" based on their corresponding 4d sub-arrays, you can sort your data usingqsort
. The doc I linked has a small example at the bottom, you should be able to adapt it to your needs. – NegativismdataValue
asdataValue[35][10][230][27][400]
or are you saying that there are 35 possible values foralgorithm
, 10 forlength
, 230 forduration
, etc? – Preference