From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-13-2010 10:05 AM
function 'Sort 1D array'
I wanted sort Array of Clusters [number and Class]. But to my surprise LV is not like it.
OK, I don't need sort Array of Classes. But maybe one time in future I will. 🙂
When 'Search 1D array' is working with classes I don't understand why 'Sort 1D array' is not working.
This problem is in LabVIEW 8.2, 8.5 and 2009
Solved! Go to Solution.
04-13-2010 10:11 AM
I would think that the Search 1d array function can deal with each element in the array as an agregate while to sort requires accessing the private data within the class data and carrying this even farther...
Say all of the elements are of class Parent and one tow children which both have private data that are uniqie from each and not present in the parents class...
How do handle tie-breakers when there are different fileds to sort on?
Ben
04-13-2010 10:17 AM - edited 04-13-2010 10:22 AM
My goal is have cluster [number and class]. Number is fitness of Class.
I don't need sort Array of Classes.
You are right there could be problem with private data in class and with children's new data.
Why Search 1D Array is working [I didn't test it]?
P.S.: I could hide Class in Variant in cluster and after everything will be fine 😉
04-13-2010 10:47 AM
JCC (SK) wrote:
Why Search 1D Array is working [I didn't test it]?
Because searching an array is defined - is this element in the array or not?
Sorting is not defined, because different classes are different data types and each data type needs its own definition for sorting (e.g. for strings, you need to decide whether b>C, etc.). You can implement your own sort VI for your class hierarchy, which will accept an array of these classes and use whatever logic you want to sort the array.
04-13-2010 10:50 AM
04-13-2010 10:57 AM
JCC (SK) wrote:Guys! You are not helping me!
🙂
So this is not an achedemic Q?
In that case I'll throw out an idea to get the conversation started.
In the parent class create a method that returns the ranking for that object instance. Sort the rankings and then apply that sort back to the original array.
Ben
04-13-2010 11:00 AM
04-13-2010 11:59 AM
JCC (SK) wrote:
I could program everything but I hoped that something will LV/NI do 😉
How can NI do anything? Sorting an array of objects is completely meaningless without an algorithm, which you have to provide. I'm not sure what the problem is, since building such a VI should be very simple once you decide how you want to sort the data.
04-13-2010 04:12 PM - edited 04-13-2010 04:12 PM
I don't see any compelling reason why we should break that wire. Putting arbitrary data in an array of clusters along with something to sort by is a really common use case. I've filed CAR# 219940 on this issue. Incidentally, the broken wire has been the behavior since LV Classes were introduced in LabVIEW 8.2.
04-14-2010 06:33 AM
Darren wrote:I don't see any compelling reason why we should break that wire. Putting arbitrary data in an array of clusters along with something to sort by is a really common use case. I've filed CAR# 219940 on this issue. Incidentally, the broken wire has been the behavior since LV Classes were introduced in LabVIEW 8.2.
Message Edited by Darren on 04-13-2010 04:12 PM
To sort you have to get at the stuff in the private data and you aren't allowed to look a that outside the class. Beraking the wire enforces that. Seems right to me.
Even if we say operators are allowed, an empty parent class with two different children one with a numeric and another with just a string, how to define a sort of tht type?
So how is this a bug?
Ben