Sorting numbers based on value into arrays

Hi ...
I currently have a large list of numbers inside an array.. say from 0 to 400 000. They appear in order, but are unevenly spaced.
Now I'd like to sort these numbers into arrays.
I want to say: Put all numbers from 0 to 10 into newArray[0]. Put all numbers from 10 to 35 into newArray[1] ....
In the end I need a two - dimensional array with numbers. Is this possible in LabView ? Can it be done in acceptable speed ?
Thank you for your help   

While I haven't figured out a way to do this efficiently, the attached
shows a method of doing it number by number.  Perhaps the most
efficient may be to insert Matlab code and use a sort function, or
equivalent in c.
To use this to sort multiple numbers, put inside a for loop and build up an array. (also see attached).
Message Edited by Robert.Bedford on 09-19-2005 08:53 AM
Attachments:
single_number_sort.vi ‏18 KB
array_sort.vi ‏21 KB

Similar Messages

  • Want to sort HashMap based on Values with duplicate values

    Hi. I have a requirement to sort the HashMap based on the values not on the keys. My HashMap contains the values which are duplicates. My program is some thing like this.
    Map m = new HashMap();
    m.put ("Gosling", new Integer(2000));
    m.put ("Joy", new Integer(2000));
    m.put ("Schwartz", new Integer(3000));
    m.put ("Bracha", new Integer(4000));
    m.put ("Gafter", new Integer(3000));
    still i need to sort HashMap based on the values. How can i do it. I want the output some like this.
    Gosling 2000
    joy 2000 (may be interchanged)
    Schwartz 3000
    Gafter 3000 (Same as above)
    Bracha 4000
    Thanks.

    I found syntactical problems with above mentioned code.
    Here is edited working version:
    * test sortMap
    public void testSortMap () {
         Map m = new HashMap();
         m.put ("IGGHHG", new Integer(232353453));
         m.put ("ASDF", new Integer(345555000));
         m.put ("DSF", new Integer(345555000));
         m.put ("XYZ", new Integer(45555555));
         m.put ("AAA", new Integer(0));
         ArrayList outputList = sortMap(m);
         int count = 0;
         count = outputList.size();
              while(count > 0) {
                   Map.Entry entry = (Map.Entry) outputList.get(--count);
                   System.out.print("Key:" + entry.getKey());
                   System.out.println("\tValue:" + entry.getValue());
    * This method will use Arrays.sort for sorting Map
    * @param map
    * @return outputList of Map.Entries
    public ArrayList sortMap(Map map) {
         ArrayList outputList = null;
         int count = 0;
         Set set = null;
         Map.Entry[] entries = null;
    //     Logic:
    //     get a set from Map
    //     Build a Map.Entry[] from set
    //     Sort the list using Arrays.sort
    // Add the sorted Map.Entries into arrayList and return
         set = (Set) map.entrySet();
         Iterator iterator = set.iterator();
         entries = new Map.Entry[set.size()];
         while(iterator.hasNext()) {
              entries[count++] = (Map.Entry) iterator.next();
    //     Sort the entries with your own comparator for the values:
         Arrays.sort(entries, new Comparator() {
         public int compareTo(Object lhs, Object rhs) {
         Map.Entry le = (Map.Entry)lhs;
         Map.Entry re = (Map.Entry)rhs;
         return ((Comparable)le.getValue()).compareTo((Comparable)re.getValue());
              public int compare(Object lhs, Object rhs) {
         Map.Entry le = (Map.Entry)lhs;
         Map.Entry re = (Map.Entry)rhs;
         return ((Comparable)le.getValue()).compareTo((Comparable)re.getValue());
              outputList = new ArrayList();
              for(int i = 0; i < entries.length; i++) {
                   outputList.add(entries);
         return outputList;
         }//End of sortMap

  • Insert group based on values in array

    Is it possible to do the following:
    formula 1
    currentdate - 9
    formula 2
    currentdate - 2
    create another formula that will store the dates in between formula 1 and formula 2 into an array and then insert a group based on each value in this array?
    Thank you in advance,
    Zack H.

    Yes it is possible but luckily you don't need to engage this difficult (and inefficient method). If you absolutely do need it after reading this post, then give a shout.
    @f_begin
    currentdate - 2
    @f_end
    currentdate - 9
    Then in Select Expert:
    {mytable.myDateOrDateTimeColumn} In In {@f_begin} To {@f_end}
    The create a group by pressing the Group Expert button Click on Options... button and choose "Section will be printed by: for each day". Order as you wish.
    No arrays needed.
    Does this do the trick for you?

  • Sorting HashMap based on values

    I need to sort a hashmap based on the values, but also need to keep the keys available for retrieving the values.
    Example:
    key value
    1 c
    2 a
    3 b
    Desired Result
    2 a
    3 b
    1 c
    Thanks for your help.

    You can do this by getting all the Map.ENTRY values in a HashMap object then using a custom Comparator object to sort them by value.
    like this:
    HashMap hashMap =  // your HashMap
    Set entrySet = hashMap.entrySet;
    /* Now add them into a list and use the Collections
    * class to sort them.
    ArrayList list = new ArrayList();
    list.addAll(entrySet);
    Collections.sort(list, yourSpecialComparator);Hope this helps.

  • Reading a text file and transferring values into array

    Hi,
    I have a problem. So what I am trying to do is that, I read a text file and insert specific values from the text file into an array for future needs.
    But I have to make sure that there is no duplicate entries. So thats what I have but, my method takes forever to finish...
    here is my code:
    String nomFichier = "Test_" + numTest + "_" + date + ".txt";
            String ligne = "";
            int z = 0;
            int j = 0;
            BufferedReader lecteurFichier = new BufferedReader(new FileReader(nomFichier));
            while ((ligne = lecteurFichier.readLine()) != null) {
                if (z > 3)
                    String valeur = "";
                    String dist = "";
                    boolean unique = true;
                    String [] chiffre = ligne.split(";");
                     if (intervalleAnalyser == 1)
                        valeur = chiffre[3];
                        dist = chiffre[4];
                    if (intervalleAnalyser == 2)
                        valeur = chiffre[2];
                        dist = chiffre[4];
                    if (intervalleAnalyser == 3)
                        valeur = chiffre[1];
                        dist = chiffre[4];
                    if (z == 4) {
                        intervalleDiagramme[j] = valeur;
                        j++;
                    if (z > 4) {
                        for (int i = 0; i < intervalleDiagramme.length; i++)
                             for (int x = 0; x < i; x++)
                                 if(intervalleDiagramme[i] == intervalleDiagramme[x])
                                    unique = false;
                        if (unique)
                            intervalleDiagramme[j] = valeur;
                        j++;
                z++;
            lecteurFichier.close(); // toujours fermer le fichier

    Hi,
    Thanks for your reply,
    1) Yeah I have a method that asks the question and assigns it to a variable.
    2) Well the z will stop once there is no lines to read no?
    for the set.add(), I am not that familar...
    I changed bit a code and I have this now:
    if (z > 4) {
                        for (int i = 0; i < intervalleDiagramme.length; i++)
                            System.out.println(intervalleDiagramme);
    if(intervalleDiagramme[i].equals(valeur))
    System.out.println(intervalleDiagramme[i] + " " + valeur);
    unique = false;
    if (unique)
    intervalleDiagramme[j] = valeur;
    EDIT:
    I figured a way to assign " " to all the values in my array. But I get this error:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 380
    at TP3.lireFichier(TP3.java:305)
    And my line 305 is: intervalleDiagramme[j] = valeur;
    EDIT2:
    So ok I found my mistake and corrected it. But I want to know is there a way of doing this without setting the size of the array? because sometimes there needs to be 21 values sometimes 19 and sometimes 20....
    If I take out: = new String [21] out I get a NullPointer error...
    Edited by: Ara1992Habs on Dec 13, 2009 7:29 AM
    Edited by: Ara1992Habs on Dec 13, 2009 7:37 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Sort column based on value

    Hi All,
    Query result gives ou put like in the following order
    CITY NAME
    CHENNI
    DELHI
    LONDON
    RIO DEGENERO
    How to get output in the following sort order
    LONDON
    CHENNAI
    DELHI
    RIO DEGENERO
    i dont want to hardcode the column values ..it will be great if i get option to genrate dynamically.
    Thanks!

    Hi,
    user601042 wrote:
    Hi All,
    Query result gives ou put like in the following order
    CITY NAME
    CHENNI
    DELHI
    LONDON
    RIO DEGENERO
    How to get output in the following sort order
    LONDON
    CHENNAI
    DELHI
    RIO DEGENERO
    i dont want to hardcode the column values ..it will be great if i get option to genrate dynamically.If the sort order isn't hard-coded, how do you get it?
    If you call a function to get the sort order, then just call the function in the ORDER BY clause:
    ORDER BY  sort_key (city_name)If the sort order is in a table, join to that table, so you can use the appropriate column
    FROM     table_x  x
    JOIN      cities   c  ON  c.city_name = x.city_name
    ORDER BY  c.sort_key
    user601042 wrote:... i want to display the following order in screen
    3 LONDON
    1 CHENNI
    2 DELHI
    4 RIO DEGENEROThe question is, how do you determine that order? I don't see anything obvious in the data itself.
    If you were sorting by the id, either ascending or descending, then 1 wouldn't come between 3 and 2.
    If you were sorting by alphabetic order, either ascending or descending, then 'CHENNI' wouldn't come between 'LONDON' and 'DELHI'.
    If you were sorting by the length of the name, either ascending or descending, then 'DELHI' (5 characters) wouldn't come between 'CHENNI' (6 CHARACTERS) and 'RIO DEGENERO' (12 characters).
    By what are you sorting? If you can explain it in English, then someone can help you code it in SQL.
    Edited by: Frank Kulash on Oct 17, 2012 2:40 PM

  • Insert element into array problem

    Hi,
    I have problem about how to insert value into an array. here is one section, could anyone help me to insert input value into array and delete the first value in the array. Gap means to fill in code
    void Ins(String name)
    // Insert name or increment its multiplicity.
    // If the bag is full remove the oldest entry.
    int i; // Running index on BagName
    int target; // if target < n then name.equals(BagName[target]);
    // else target == n
    Date EntryDate; // Current date and time
    // Get current date and time
    EntryDate = new Date();
    BagDate[n] = EntryDate.toString();
    Mult[n] = n+1;
    BagName[n] = name;
    n++;
    // Search bag for name
    // Gap 2
    // Assertion: target < n => name.equals(BagName[target])
    // else target == n
    // Update Mult if target < n
    // Gap 3
    // Make room for and insert name if target not found
    } // Ins(String name)
    Message was edited by:
    sibojava
    Message was edited by:
    sibojava

    Do you have several accounts?
    See this thread, it's the same question:
    http://forum.java.sun.com/thread.jspa?threadID=5143232
    Kaj

  • Array of different (digital and analog) values into multigraph

    Hello everyone,
    So I have an array with a timestamp on the first column, either "off" or "on" string on the second column, and a number value string on another. The columns are based of variables that reads data based on an update rate. My question is, what is the easiest way to separate these values into a digital and analog graphs. This is because the number values are so high that the "off" and "on" signal is being pushed down as the y-axis auto-scales. I'm hoping that I can use a multigraph, but the multigraph puts the data in one graph (since it's one array). 
    Any suggestions or help is appreciated.

    Hi jachy25, 
    Below is a link to a KnowledgeBase article that goes over how to use stacked plots in LabVIEW.
    http://digital.ni.com/public.nsf/allkb/21E8163F259DA2058625703B007511AA
    The second link contains a lot of general information on configuring graphs and charts in LabVIEW, and is a useful document to have when configuring plots.
    http://zone.ni.com/reference/en-XX/help/371361L-01/lvconcepts/customizing_graphs_and_charts/
    I hope this information helps!
    Regards,
    Kelly B.
    Applications Engineering
    National Instruments

  • Keybord trick to insert quickly a value into a constant array

    Hi everybody,
    I want just to know if there is a keybaord trick which allows yuo to pass quickly from an element to the next one (or to new one) while I'm typing the values into a constant array, you know if is there?
    What I mean is a keybord key as the TAB key that quickly allow you to pass from a cell to the next one into the grid control.
    Thank you in advance,
    Regards.
    Ricky
    Italian Developer engineer
    www.www.selt-sistemi.com
    Solved!
    Go to Solution.

    Darin.K wrote:
    [...] unzip the files and put them in the directory
    [LabVIEW ####]\resource\dialog\QuickDrop\plugins
    Create some cells in Excel (or other similar program), select and copy to the clipboard.  (Any tab delimited data will work).  On the FP Ctrl-Space Ctrl-e creates a control with the data in numeric form (simple check to decide DBL or I32).  Ctrl-Space Ctrl-E (shift+e) creates a string control.  Similar commands for the BD to create array constants (numbers or string).  Single rows or columns become 1D arrays, otherwise you get 2D array controls/constants.  Change the letter by renaming e.vi if you'd like.  I chose e for Excel since X was taken along with s for spreadsheet and a for array.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • How can i pass a value in array into .setText()?

    i want to display a value in an array into a JTextField. May i know how to do it?
    eg:
    JTextField UserName;
    UserName.setText(s);
    but it doesn't display the value into the JTextfield.

    ok... is s an array?
    String[] s = {"s1", "s2"};Either you expect 1 value...
    username.setText(s[0]);
    // or
    username.setText(s[1]);Or you expect both:
    StringBuffer sb = new StringBuffer("");
    for(int x = 0; x < s.length; x++) {
       if(x != 0) sb.append(", ");
       sb.append(s[x])
    username.setText(sb.toString());

  • Insert value into a column based on value of another column

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance.

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
    record, but if you are setting a value in a column of the same
    record using a trigger, then it's easy.
    :new.COL2 := ....:new.COL4...
    :new.COL3 := ....:new.COL4...
    The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
    If you are setting a different record in the same table, the
    solution is much more difficult.

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • Update/Insert into two fields based on value of one.

    How would I do the following in ADDT.
    Example:
    I have a database about dogs. When user completes form they make a selection from a recordset feed drop down box of breeds. Lets say they select "PUG" based on the selection two fields are populated from the same recordset size="small" and color="brown".
    I hope I've explained this well enough
    Thanks!
    Rich

    >>
    I think I understand. I'm using two forms One to select the item from a list. I'm passing that items value to the next page where I'm placing that value into a query which will give me the options available based on the query results?
    >>
    what I meant, is first have the user insert the new record and let him specify the desired "breed" already there -- the following page(s) will need to make sure that he´s going to update the newly inserted record with additional values, that´s why you should use the "SELECT dog_id FROM dog_table ORDER BY id DESC LIMIT 1" - query on page 2. However, once this new record had been clearly identified "by id", you can add whatever options available in the secondary table which are related to the "dog_id" (breed) that has been stored when inserting the new record. Maybe *I* don´t get it, lol ;-)
    >>
    I currently do this the dropdown value to a case statement that takes the value of the dropdown and determines the correct values for the database update
    >>
    OK, but when each dog just has one option
    (thought it were two ones: "color" and "size"), isn´t your existing dependant dropdown enough for specifying that "based on breed" option without having to use a hidden field at all ? Ah well, have you ever used ADDT´s / Kollections "dependant drop-down" wizard -- that should do it for one option
    >>
    hidden field that I need to update value based on what the value is above
    >>
    humm -- updating the value of a hidden field in the very same page then ? Never heard of this being possible apart from using some hand-made javascript.
    Guess I gotta ask my dog what it thinks about all that :-)
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • How to convert a waveform signal into array of complex numbers

    How to convert a waveform signal into array of complex numbers.

    Hi Chaks,
    try this:
    (Get Waveform components, convert to complex DBL)
    Message Edited by GerdW on 01-28-2008 09:23 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    ToCDB.png ‏1 KB

  • Pass the Sting value into date array

    Hi,
    i want to pass the stirng value into date array. how is it possible...
    eg.. i am getting the value as sting i.e String str = "10/31/2006";
    now i want to store this value into date array.. i.e new Date[]{date};
    i want to store that string as date.....
    plz help me

    Hi,
    i want to pass the stirng value into date array. how
    is it possible...
    eg.. i am getting the value as sting i.e String
    str = "10/31/2006";
    now i want to store this value into date array.. i.e
    new Date[]{date};
    i want to store that string as date.....
    plz help meUse java.util.SimpleDateFormat
    :)

Maybe you are looking for

  • CLOB and ADO

    I have a table with a CLOB field that I need to retrieve using ADO 2.5 and OLEDB Provider for Oracle, 'MSDAORA.1'. Everytime, I try to open up the table and get the following error, 'Data Type Is Not Supported'. Thanks.

  • SSO and REMOTE_USER

    Hi everybody, Once authenticated to HTML_DB through SSO, is there a way to know the REMOTE_USER (the username entered by the user when authentified by SSO) and use it in a query ? Thank you

  • Creating InfoSources in BI 7.0

    Greetings from Manila! I'm new to the BI world and as such, am learning from doing.  I got training from SAP Solutions Academy last year for BW 3.5 but have only begun using BI now.  Challenge is I'm using BI 7, which is slightly different from using

  • Click on jsp page Display records on another html page

    Hi All, I am new in jsp. I am making discussion forum. I have one jsp page "Post.jsp" I want when I clicked on submit button on jsp page all records display on html page "index.html". Plz. help me. Raj

  • Safari 7.0.4 update, kb HT1222

    The Safari 7.0.4 update web page redirects to other page of kb HT1222 for update's more details - a hyperlink. The hyperlink destination however does not mention any single word about Safari 7.0.4. That's the quality made by Apple!!!! Not the first i