[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Array Sorting



PureBytes Links

Trading Reference Links

List,

I am writing some code trying to sort a multidimentional array.
Though someone would help with already existing efficient algorithms.

This array is [2 ,1000 ] 2  rows by 1000 columns.
The first row is filled at random with data values that are unique.
The second row is filled with freequency distribution of the 
corresponding unique data value from the first row - just like an
# of occurrences counter. 

Anyway, once the array is filled I would like to sort it in 
ascending order in the first row but at same time I would like to 
move  the values in the second row with the values in the first 
as I am sorting the first. 

I hope that make sense but here is an example below;

	C1  C2  C3  C4  C5  .... Cn

R1	3    9   2   5   4	  7		- Unique Values

R2	20   4	 14  33	 27       25  		- # Occurrences

	Need to sort the above to:

	C1  C2  C3  C4  C5  .... Cn

R1	2    3   4   5   7	  9		- Unique Values

R2	14   20	 27  33	 25       4  		- # Occurrences

Tricks: the array will not necessarily be filled to max,
	the smallest value in row 1 will not necessarily be 0 or 1.
	dont have to sort on each bar only end of chart.
	needs not to be super fast but not slow either. 
Can anyone help a bit here?
This array then will be used for statistical  analysis of the value 
in Excel or Matlab ( min, max, mean, median, std, etc. ). 

Any code examples would be appreciated.

Thanks,

Val.