LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

1D array sort not working (7.0)



@Gabriela Tillmann wrote:
Thanks again for your time.
So it is a bug. And I thought that all sorting algorithms were weatherproof since ages.....



Gabi,

Last spring, some of us have studied sorting algorithms in quite some detail, as it was needed for the Median Coding Challenge (see the results).

While it is easy to write a dumb sorting algorithm, it is quite challenging if you want it to be very, very fast even with "pathological" input arrays (sorted, reverse sorted, patterned). My wild guess is that the pivot selection algorithm somehow hits a weird edge effect in the LabVIEW 7.0 version of the code.

Some other interesting observations: If you "rotate" your input array (no size change), the result is incorrect for rotations or 0 to -8 and some show only very subtle errors, not directly visible in the graph. Most other rotations I tried yield the correct result.

I think the error is rare enough that two " Sort 1D array" in series will always produce a correct result. The first step will remove the strong "pattern" in the input, which is most likely the cause of the problem. Of course you could also write your own sorting VI directly in G. 🙂
0 Kudos
Message 11 of 11
(431 Views)