Sort Second Element in Array of Strict Type Def Clusters

I need to sort the an array of strict type def clusters by the second or third element in the cluster.  In the past I have used 1-D array sort and sorted by the first element of the cluster.  When I need to sort by the second, third, or fourth element of the cluster I just break down the cluster and rebuild it placing the desired sort element in the first position of the new cluster.  This works for simple tasks and clusters, but as the cluster gets more complicated this becomes a pain to do this.  There must be a cleaner way to sort by other elements within the original array of strict type def clusters.  Has anyone succeeded in doing this a different way?

Hello,
Here's the way I would do it...just create a new cluster array, where each cluster contains two elements...the unbundled item you want to sort by, and the cluster itself.  Then sort the new cluster array, then unbundle the sorted cluster array to get the original clusters (now sorted).  Here is a screenshot:
There may be a better way, but this is the first thing I thought of.
-D
Message Edited by Darren on 03-16-200610:00 AM
Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Attachments:
Sorted_cluster.jpg ‏30 KB

Similar Messages

  • Array of strings strict type def not updating

    I have defined an Array of Strings (ctrl) as a strict type def. When I update this array (add another string to it) the values don't update where this control is used. Can someone please explain why this is occuring.

    Only the size of the array _shell_ is locked, not the size of the array data. The array shell is a window into the data of the array control. If you change the value of the index display you will change the indices visible inside the array shell.
    -Jim

  • Setting control to default value when it is a strict type def

    If my subVI has a control that happens to be a strict type defined cluster and I have saved the values in the control as the default values, how can I change them back to the default values of the type def (which are empty).  Because it is a strict type definition, i cannot click on the elements inside the cluster and modify them (e.g. click on an array inside the cluster and do an empty array operation.)
    In the attached screenshot, the control "BLE Meters To Test" is just an array of clusters and I was able to empty the array.  The control "Capture Data" is a strict type def.  I would like to clear the contents of this control without having to delete the control and add it back with a new instance of the same strict type def.
    Solved!
    Go to Solution.
    Attachments:
    screenshot.PNG ‏33 KB

    are you talking about edit mode or run mode?
    You could temporarily add a second instance of the typedef (all empty), then change it to a constant. Whenver you need to reset at run time, write the new digram constant to a local variable of the control.
    glstill wrote:
    Because it is a strict type definition, i cannot click on the elements inside the cluster and modify them (e.g. click on an array inside the cluster and do an empty array operation.)
    Make sure to click on the array container, not on the array elements.
    LabVIEW Champion . Do more with less code and in less time .

  • Change strings of (strict type def) refnum

    mitulatbati wrote in http://forums.ni.com/ni/board/message?board.id=170&thread.id=233257&view=by_date_ascending&page=5:
    Hi,
    I have made a strict type def, which is a text ring. I open the VI reference -> get Panel property node -> Controls[] -> Index first element (there is only one, the ring) -> change Strings and values, and then close reference.
    If I call this subvi from a VI, which includes this strict type ring, it will be only updated, when I restart the VI. And not in runtime. I don´t get any error, everything looks fine, but the strings and values are not updated :-(
    Is there a way not to restart the VI, but to modify the ring programatically?
    regards
    MB
    Message Edited by shb on 07-29-2008 11:52 AM

    Hello mitulatbati,
    I do something similar with a Combo Box. The reference to each box is stored in an unitinialised shift register of a VI. When I want to change the selectable text, I do it in a for loop for every stored control.
    A VI doeing this for Rings is attached (LV8.2.1).
    Greetings,
    shb
    Attachments:
    Demo - Update Ring synchron.vi ‏21 KB
    Update Ring synchron1.vi ‏14 KB

  • How to change the font color in a strict type def programatically

    Could someone suggest a way to change the font color of a string indicator in a strict type def cluster programmatically? The cluster contains a label that is color-coded to match the function of the data channel represented by that cluster.  The function of each channel is not predetermined, so the font color needs to be changed programmatically.  To represent all channels, I have arranged a large cluster that contains 100 instances of the control.  This makes it essential that the control be strictly type defined in order to change the layout of the clusters uniformly.
    Can anyone suggest either a method by which I can let the control remain a strict type def and change the font color, or a method by which I can programmatically change the control from a strict type def to a type def?  Currently, I am saving the control as a strict type def every time I make a change and then saving it again as a type def when I am ready to run the program.  This works fine, but just seems inelegant.  This color-coding is used throughout the program in various indicators, so a neat solution would be greatly appreciated.

    As mentioned in my Nugget on Type definitions you can create strict type-defs that contain type-defs.
    If you make your data definition a type and put that definition in a strict type-def (one of each flavor) you can use the appropraite strict type where each is required.
    Yes the data structure will have another level of nesting so if you are "too far gone" you may not like this idea.
    Otherwise you can write a VI that opens the typed-def and do a "save as..." and use it everytime you edit the type-def.
    I hope something helps!
    Ben
    Message Edited by Ben on 10-06-2008 10:26 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Strict_of_Typedefs.PNG ‏30 KB

  • About Strict Type def

    Hii
      i have created a cluster of ring control as a strict type def.Also i have used a constant of that cluster in my program where  i need.Now am changing the items in that ring control by opening the strict type def.I am giving Apply changes , save and all.Now the cluster in my program is changed.But my constant remains unchanged.;..How can i update a constant...

    The wonders of searching (and that's just one of the results for my simple search).
    Try to take over the world!

  • How can I change the numeric and enum default values in a Strict Type Def Cluster?

    I have a Strict Type Def cluster that contains 10 Numerical controls and a number of enums.  I have edited default values of the numerical controls in the Strict Type Def, in customize mode, performed a "Make Current Values Default"  and have done a "Apply Changes"  and saved.
    This cluster is used in various locations throughout the project and have not found a way to make the cluster default values change downstream.  The Strict Type Def (STD) Control appears to have the right values on the front panel.  But if I place an instance of this on a blank front panel, and run a wire from it in the block diagram with a probe and indicator, I still get the old default values being passed from the STD.  
    Solved!
    Go to Solution.

    There Are No Strict Type Definition Constants
    "Even though typedefs only update when types change, instances get cosmetic changes from the definition whenever they update. So one trick to "push" changes to typedef instances is to change the data type, apply changes, and then change the data type back. [edit, March 26 - Note that the typedef instances need to be in memory when you use this trick]."
    From Eyes on VIs, here.
    http://blog.eyesonvis.com/
    I love this article.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • How to edit the appearance of one instance of a type def (not strict)?

    Hello,
    I would like to edit the appearance of a control (changes which require using the LV control editor).  Unfortunately, this control is an instance of a (non strict) type def.  How do I do this, without editing the appearance of the type def itself?
    Thanks,
    Jaegen

    Hi Jaegen, this worked for me...
    Open the typedef - don't worry, you aren't going to _save_ changes
    Edit typedef as needed
    [When done editing] copy connector-pane (select, ctrl-C)
    File\Revert !!!
    Select target-control and paste!
    In LabVIEW 7.1, the edited/pre-reverted ... ouch ... control appears (and still connected to typedef).
    Message Edited by Dynamik on 11-16-2005 08:22 PM
    Message Edited by Dynamik on 11-16-2005 08:23 PM
    Message Edited by Dynamik on 11-16-2005 08:24 PM
    When they give imbeciles handicap-parking, I won't have so far to walk!

  • No Data Change event generated for a XControl in a Type Def.

    Hello,
    Maybe I am missing something but the Data Change event of a XControl is not called when the XControl is used in a Type Def. or Strictly Type Def. (see the attached file).
    There may be some logics behind it but it eludes me. Any idea of why or any idea of a workaround still keeping the Type Def. ?
    Best Regards.
    Julian
    Windows XP SP2 & Windows Vista 64 - LV 8.5 & LV 8.5.1
    Attachments:
    XControl No Data Change event.zip ‏45 KB

    Hi TWGomez,
    Thank you for addressing this issue. It must be a XControl because it carries many implemented functions/methods (though there is none in the provided example).
    Also consider that the provided non-working example is in fact a reduction of my actual problem (in a 1000-VI large application) to the smallest relevant elements. In fact I use a  typedef of a mix of a lot of different XControls and normal controls, some of them being typedef, strictly typedef or normal controls and other XControls of XControls (of XControls...) in a object oriented like approach...
    Hi Prashant,
    I use a typedef to propagate its modifications automatically everywhere it is used in the application (a lot of places). As you imply a XControl would do the same, though one would like to construct a simple typedef when no additional functionality is wanted.
    The remark "XControl=typedef+block diagram" is actually very neat (never thought of it that way) because it provides a workaround by transforming every typedef into a XControl. Thanks very much, I will explore this solution.
    One issue remains: All normal controls update their displayed value when inserted into a typedef but not XControls. Data change event is not triggered. I known that XControls have some limitations (no array of XControls) but I would say, like TWGomez, that this is a “bug” considering the expected functionality.

  • Changes to Text Ring Items in Type Def not Updated in Copies

    In LabVIEW 2010, I have Type Definition which is a Cluster that contains several Controls including a Text Ring control.
    If I go into the Type Definition and Edit the Items in the Text Ring, those changes to the Items in the Text Ring do not show up in the "copies" of the Type Definition control on my Front Pane, even though the "Auto-Update from Type Def." feature is checked.
    How do I get changes to the Items in a Text Ring in a Cluster in a Type Definition Control to show up in all of the "copies' of the Type Definition on my Front Panel?
    I shouldn't have to edit the same Items in the same Text Ring in multiple places.

    What you see is normal behaviour of rings. The general advice is to use an enum instead of a ring. Rings are useful as FP elements which you want to populate during run-time.
    I guess this is the best option you have, replace the ring by an enum inside your type def and hope it's all fine...
    Another option you can try if you need to have it as a ring, is to make it a strict type def. I'm not sure but I would expect it to propagate the ring text to all instances. On the other hand, you can't programmatically set the ring text as long as it's a strict type def, so to get the bahviour of a ring again, you will need to revert back to a normal type def.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Type defs changes not reflected in block-diagram constants?

    I'm struggling with strict type-defs today.
    If I create a strict type-def, say of a cluster with an enum in it, and save it. Then create a block-diagram constant from the strict type-def in a blank vi. Then make changes to the strict type-def (say, add another item to the enum), the block-diagram constant ghosts out , as it should. If I then select "Apply changes" from the strict type-def menu, the ghosted block-diagram constant becomes un-ghosted, as it should. BUT, it hasn't update!? If I look for the new item in the enum, it isn't there!? I'm sure it should be, right?
    No changes that I'm making to my type-defs or strict type-defs are being reflected in my block-diagram constants (which are definitely still linked to the controls with "Auto-update from type-def" checked on). It does work for front panel controls and indicators though - just not block diagram constants.
    I'm using LabVIEW 8.5.1, Win XP Pro. Any ideas anyone?
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

    Solved. I think.
    I tried a range of type-defined controls, including an enum, a ring list, a cluster with an enum inside it, and a cluster with a ring list inside it.
    Changes to the enum items were reflected in all vi controls and block diagram constants.
    Changes to the ring list items were not reflected in the controls or block diagram constants.
    This snapshot shows the the last item available in each ring and enum list. Clearly the rings were not updated when the custom controls were. (Yes, I applied changes and saved too).
    Switching to strict type-defs only impacted  the front panel controls, as Ben highlighted, because this is GUI related. You can see from this second snapshot where all type-defs are now strict type-defs that all enums and rings updated to reflect all three items, but the block diagram rings are still out of date
    I expect somebody will tell me now that this is normal behaviour??? 
    Message Edited by Thoric on 09-10-2008 02:31 PM
    Thoric (CLA, CLED, CTD and LabVIEW Champion)
    Attachments:
    custom_control_test.jpg ‏53 KB
    custom_control_test_stricttd.jpg ‏54 KB

  • Sort 1D array of clusters by the second element in the cluster

    Hello Folks,
    I need to sort 1D array of clusters [Point (X & Y)] using the second element (Y) of the Point cluster. Can anyone guide!!!!
    Thanks.
    Manu

    I see Darren is a bit faster than me.
    Here's my solution (LabVEWI 7.0), it is pretty similar.
    Message Edited by altenbach on 03-22-200602:01 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SortByElement2.png ‏4 KB
    SortByElement2.vi ‏27 KB

  • Can I sort by the second element in my vector?

    The first element is first name and the second is lastname. Right now I am using java.util.Collections.sort(v); This searches on the first name. I would like to search on the last name which is the second element. Any ideas?

    Write a subclass of Comparator that looks at the second element, and give an instance of it to the sort method along with the array.

  • Sort an element out of 2-D array

    Hi guys, how to sort an element out of a 2-D array. For example I like to know the value of element in array[0][1].
    Solved!
    Go to Solution.

    The index array function would be a good start.
    Have you even tried it?

  • Can I sort on the second element of my vector?

    Sorry to intrude on the guru territory, but no one in the newbie camp has answered and I am sure someone over here has a quick answer...
    The first element is first name and the second is lastname. Right now I am using java.util.Collections.sort(v); This searches on the first name. I would like to search on the last name which is the second element. Any ideas?

    I'm not sure what's in your vector. I assume the vector contains strings, of the form "firstname lastname". In which case I suspect the default implemetation of sort is simply sorting the strings in the natural way. If you look at the second implementation of sort():
    sort(List l, Comparator c)
    you can implement your own comparator. The comparator is an interface tast you implement to compare two object the way you want th sorting done.
    so your comparator would implement compare to find the second word of each string (look at string tokenizer for this) and compare them (with String.compareTo). You need to do something similar with equals.
    So you call sort like this: sort(myVector,new MyComparator());
    Hope this helps.

Maybe you are looking for

  • Unlocked Nokia Lumia 900

    The unlocked Lumia is going for $499 at AT&T. I really don't want to go through the hassle of the Early terming my contract and was just going to buy the Lumia outright and have it replace my Torch on my Verizon plan. Is that doable? What things shou

  • RDS 2012 External access for Session Hosts over different port to default 443

    Hello there I am having problems solving this problem as you may see on other posts, so I am going to try again. I have two Server 2012 machines for RDS. Server 1 one with all roles (Gateway, Broker, Session host etc.) and second machine, Server 2 as

  • Cannot browse the net

    i recently purchased  WRT54GS and since the day i bought it i am having this issue where i cannot browse eventhough i see the the wireless network connection icon strength showing either excellent or very good, several times i have taken online help

  • Message waiting light

    I would give my right arm to be able to look at my iPhone while it's asleep and see some indication that I have a message waiting - text, email or voice. Maybe a few flashing pixels with different colors for different types of message. Most other pho

  • Small Window Program

    I want to write a small program for window user. The program allow user to search specific computer in the local network. The result screen show out the ip address information and there are some buttons to perform different actions. Is that I use Jav