LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

2D matrix sorting...

Hi...

I want to sort a 2D matrix ... decreasing order ... "m_piece[1000][5]" on the first column of the matrix...

I know that there is the CVI function... HeapSort with IntCompare ... But how I make the call...

Best Regards...

Steph
0 Kudos
Message 1 of 4
(3,602 Views)
Hi Steph, I've attached some source code with two versions in... both use the HeapSort & IntCompare functions that you mentioned, but due to the organisation of your array (1000x5 as opposed to 5x1000) the HeapSort function doesn't quite work right... So the 1st version uses a temporary array to hold the data from one of the 1000 element data sets to be processed by the sort routine. The second version changes the 2D array to a 5x1000 one, and then can simply pass the pointer to the 2nd dimension as the argument to the HeapSort function.
As it stands the HeapSort sorts the array in ascending order. If you want descending order, simply switch the arguments in the IntCompare function call

Hope this helps
JB
Message 2 of 4
(3,602 Views)
Hi.

I've done a little demo to show a couple of ways for this. If you send an
email to me, I'll send it off.

Triffid.

"Steph" wrote in message
news:506500000008000000A5470000-1019262487000@exchange.ni.com...
> Hi...
>
> I want to sort a 2D matrix ... decreasing order ... "m_piece[1000][5]"
> on the first column of the matrix...
>
> I know that there is the CVI function... HeapSort with IntCompare ...
> But how I make the call...
>
> Best Regards...
>
> Steph
0 Kudos
Message 3 of 4
(3,602 Views)
Hi.

I've done a little demo to show a couple of ways for this. If you send an
email to me, I'll send it off.

Triffid.

"Steph" wrote in message
news:506500000008000000A5470000-1019262487000@exchange.ni.com...
> Hi...
>
> I want to sort a 2D matrix ... decreasing order ... "m_piece[1000][5]"
> on the first column of the matrix...
>
> I know that there is the CVI function... HeapSort with IntCompare ...
> But how I make the call...
>
> Best Regards...
>
> Steph
0 Kudos
Message 4 of 4
(3,602 Views)