Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5363

Sorting list problems in 2013

$
0
0

I'm programming by CVI.

 

However, I encounter a critical problem - the list sort built-in library does not work.

 

In both of console and real-time application, the sort result is wrong.

 

How can I solve this problem.

 

 

=================================================================

int main (int argc, char *argv[])
{
 double value1 = 3.0;
 double value2 = 4.0;
 double value3 = 1.0;
 double value4 = 2.0;
 
 double test;
 
 int i;

 ListType newList;

// if (argc < 2 || argc > 3)
//  usage (argv[0]);

 printf("This is built-in List type test program!\n");
 
 newList = ListCreate(sizeof(double));
 
 if (newList == VI_NULL)
 {
  return -1;
 }

 ListInsertItem(newList, &value1, END_OF_LIST);
 ListInsertItem(newList, &value2, END_OF_LIST);
 ListInsertItem(newList, &value3, END_OF_LIST);
 ListInsertItem(newList, &value4, END_OF_LIST);

 printf(">>>>> The original list\n");
 for (i=0; i<ListNumItems(newList); i++)
 {
  ListGetItem(newList, &test, i);
  printf("[%d] %f\n", i, test);
 }

 ListInsertionSort(newList, DoubleCompare);
 
 printf(">>>>> The sorted list\n");
 for (i=0; i<ListNumItems(newList); i++)
 {
  ListGetItem(newList, &test, i);
  printf("[%d] %f\n", i, test);
 } 

 
 if (newList)
 {
  ListDispose(newList);
 }

 return 0;
}

=================================================================

 

This is built-in List type test program!
>>>>> The original list
[0] 2.000000
[1] 3.000000
[2] 4.000000
[3] 1.000000
>>>>> The sorted list
[0] 4.000000
[1] 1.000000
[2] 2.000000
[3] 3.000000

 


Viewing all articles
Browse latest Browse all 5363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>