sorting in Netlinx
MorgoZ
Posts: 116
Hello!
It´s a simple question:
Is there a "sorting" module or function to do "smart sorting" in NetLinx, like quicksort and so? Or should i implement a sorting algorithm by myself?
Thanks!
It´s a simple question:
Is there a "sorting" module or function to do "smart sorting" in NetLinx, like quicksort and so? Or should i implement a sorting algorithm by myself?
Thanks!
0
Comments
You will need to create your own sorting methods.
Thanks for that link, a very interesting read.
The link of jjames was really helpfull, i´m finally using a Shell sort.
Here is the code of the Shell sort, which is the same as the Spire_Jeff´s. But i think that it could be useful to post the raw code; just the Shell sort algorithm, since the code posted at the link is not easy to understand at first sight
<code>
DEFINE_CONSTANT
//GAPS for Sedgewick sequence
GAPS[] = {1968, 861, 336, 112, 48, 21, 7, 3, 1}
DEFINE_VARIABLE
volatile integer numFind, indGap, nTemp, length_GAPS
DEFINE_START
length_GAPS = length_array(GAPS)
(.......................................)
/***** Shell Sort Algorithm ******/
/*** for array A ***/
numFind = length_array(A)
indGap = 1
while (GAPS[indGap] > numFind )
{
indGap++
}
while (indGap<= LENGTH_GAPS)
{
k = GAPS[indGap]
for (i=k+1; i<=numFind ; i++)
{
j = i
while (j > k && A[j-k] > A[j])
{
nTemp = A[j]
A[j] = A[j - k]
A[j - k] = nTemp
j = j-k;
}
}
indGap++;
}
</code>
It can be also used for a string array.
Salutes!!
Thanx!
You can wrap code in a [ code ] [ /code ] block like:
Don't put spaces between the brackets and the code and /code tags. If you get stuck, hit "Reply With Quote" on this post and it should show you how it's formatted.