Array Sort


Recommended Posts

With the heavy use of arrays in DAQFactory I was surprised to only find SortTime() function and no general array sort function. Is there one that I missed? I would like to sort objects in a class based on different properties.

 

Sorting can be loop intensive and is something that would benefit from a function programmed in C as opposed to script.

Link to comment
Share on other sites

SortTime() is mostly there to get data in the right order for trending.  DAQFactory arrays are mostly about data processing and sorting numbers is usually not something people want to do.  Sorting an array of numbers is easy to do with sorttime:

 

x.time = x

x = sorttime(x)

 

I'm not sure what you mean by sorting objects in a class.  Just to be clear on nomenclature: a class is a template for creating objects.  It doesn't exist except as a template.  An object is an instantiated class and something you can manipulate.

 

I'm moving this to the feature request forum.

Link to comment
Share on other sites

Yes, I understand classes are templates so you can't sort a class, but you can have arrays of objects whose structure is defined by a class and the class properties could be either numeric or string. I'd like to have a sort function that would allow me sort objects based on either type of variable. And it would be nice if the sort function was generic enough to sort both an array of objects and either numeric or string arrays, and to be fast like making a C quick sort function readily available to script. It might be nice to be able to sort channels by name for example, or by device ID.

 

If I have a class with two properties, say name and value, where name is a string and value a numeric variable, it doesn't look like I can use sorttime() to sort on either property.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.