Simpler way to sort 2-d string array?

I have a long 2d string array, and I would like to sort by the 2nd value. It originates as:
    public static final String names[][] = {
     {"000000", "Black"},
     {"000080", "Navy Blue"},
     {"0000C8", "Dark Blue"},
     {"0000FF", "Blue"},
        {"000741", "Stratos"},
     {"FFFFF0", "Ivory"},
     {"FFFFFF", "White"}
    };As you can see, they are pre-sorted by the hex values. That is useful for part of the app.
There are 1,567 entries. I would like to alphabetize the color names and place them in a list widget. I need to keep the associated hex color values with the name values. All I can think of to do something like:
1) make a temporary long 1-d string array
2) fill it by loop that appends the hex values to the name values: temp[i] = new String (names[1] + names[i][0])
3) sort temp[] with built in Java sort
4) make a permanent new string array, hexValues[] for the hex values
5) copy the last 6 characters of each item to hexValues[]
6) truncate the last 6 characters of each item in temp[]
7) build list widget with temp[]
Is there a more elegant way? What I'd really like to do is build a 1-d array of int's, with the values representing the alphabetized locations of the names. However, I don't see any built-in which would do that kind of indirect sort.
Second question -- Can the backgrounds of each item in a list widget be a different color? Ideally the list would show the color name in black or white, and the its color value as background. Specifically, I'm trying to build the list accomplished by the Javascript code here:
* http://chir.ag/projects/name-that-color/
and add it to my Java interactive color wheel:
* http://r0k.us/graphics/SIHwheel.html
BTW, I have converted his name that color Javascript (ntc.js) to a native Java class. It is freely distributable, and I host it here:
* http://r0k.us/source/ntc.java
-- Rich
Edited by: RichF on Oct 7, 2010 7:04 PM
Silly forum software; I can't see what made it go italic at the word new.

I am implementing a sort infrastructure along the lines of camickr's working example, above. Part of my problem is that I am new to both lists and collections. I've tried searching, and I cannot figure out why the compiler doesn't like my "new":
public class colorName implements Comparable<colorName>
    String     name, hex;
    int          hsi;
    static List<colorName> colorNames;
    public colorName(String name, String hex)
     float     hsb[] = {0f, 0f, 0f};
     int     rgb[] = {0, 0, 0};
     int     h, s, b;     // b for brightness, same as i
     this.name = name;
     this.hex  = hex;
     // Now we need to calculate hsi,
     this.hsi = (h << 10) + (s << 6) + b;  //  hhhhhhssssiiiiii
    ***   findColorName() performs 3 functions.  First, it
    *** will auto-initialize itself if necessary.  Second,
    *** it will perform 3 sorts:
    ***   -3) byHSI:  sort by HSI and return first element of sorted list
    ***   -2) byNAME: sort by name and return first element of list
    ***   -1) byHEX:  (re)reads ntc.names, which is already sorted by HEX;
    ***               returns first element of list
    *** Third, on 0 or greater, will return the nth element of list
    *** Note: ntc.init() need not have been called.
    public colorName findColorName(int which)
     if (which < -3)  which = -3;
     if (which >= ntc.names.length)  which = ntc.names.length - 1;
     if (which == -1)  colorNames = null;     // free up for garbage collection
     if (colorNames == null)
     {   // (re)create list
         colorNames = new ArrayList<colorName>(ntc.names.length);
         for (int i = 0; i < ntc.names.length; i++)
             colorNames.add(new colorName(ntc.names[1], ntc.names[0]));
        if (which == -1)  return(colorNames.get(0));
}On compilation, I receive:
D:\progming\java\ntc>javac colorName.java
colorName.java:117: cannot find symbol
symbol  : constructor colorName(java.lang.String[],java.lang.String[])
location: class colorName
                colorNames.add(new colorName(ntc.names[1], ntc.names[0]));
                               ^
1 errorLine 117 is the second-to-last executable line in code block. I know it is finding the ntc.names[][] array the ntc.class file. I had forgotten to compile ntc.java, and there were other errors, such as in line 115 where it couldn't find ntc.names.length. Compare camickr's two lines:
          List<Person> people = new ArrayList<Person>();
          people.add( new Person("Homer", 38) );As far as I can tell, I'm doing exactly the same thing. If you have any other feedback, feel free to make it. The full source may be found at:
* http://r0k.us/rock/Junk/colorName.java
PS1: I know I don't need the parenthesis in my return's. It's an old habit, and they look funny to me without them.
PS2: My original design had the "static List<colorName> colorNames;" line defined within the findColorName() method. The compiler did not like that; it appears to be that one cannot have static variables within methods. Anyway, that's why I don't have separate sorting and getting methods. I'm learning; "static" does not mean, "keep this baby around". Its meaning is, "there is only one of these babies per class".
-- Rich

Similar Messages

  • Do you know of a simple way of sorting and deleting duplicate photos on  aperture

    Hi , Do you know of a simple way of sorting and then deleting duplicate photos on Apeture.
    Thanks Phil

    There is no simple way. The best strategy really is to take care not to import duplicates.
    What is your Aperture 3 version?
    What kind of duplicates are you asking about? 
    If you imported exactly the same file multiple times, sorting your images in the Finder by filename or creation date will display them side by side.
    If you have diferently sized versions of the same image, edited versions, or versions converted to a different format, then sorting by creation date will not help; you might try to sort by capture date, but that may fail, if there were different imezone settings when you imported the images.
    You could also sort be filename, if you did not rename the images on import.
    If you renamed your versions, adjusted the date, modified the file properties by writing to the original files, try to sort by other tages - faces, location, keywords.
    There are some helper applications to scan your Aperture library and tag duplicates: (I have not really tested any of them)
    Duplicate Annihilator (Mac) - Download  good to detect accidentally imported thumbnails
    http://photosweeper.en.softonic.com/mac  : This app can actually detect edited duplicates based on statistic measures and histogram similarity.
    Duplicate Cleaner for iPhoto - free

  • I'm looking simple way XML-View from a string?

    Hi,
    there is a nice facility to show a XML-Tree in the Microsoft Internet-Explorer from a XML-file on the PC.
    Is there a simple way like this in ABAP?
    My mission is to read a XML-String from a table and to show the XML-Tree in the SAPGUI.
    I found the method CL_XML_DOCUMENT->DISPLAY, but I'm not sure how to export the XML-String to this class/object.
    Best and regards,
    Stefan

    hi,
    you can use
    call method CL_XML_DOCUMENT->display.
    data : l_string type string.
    data :lo_mxml type ref to cl_xml_document,
          m_document  type ref to if_ixml_document,
          l_dom       type ref to if_ixml_element,
          l_ele       type ref to if_ixml_element,
          l_ele1      type ref to if_ixml_element,
          m_doctype   type ref to if_ixml_document_type,
          g_ixml      type ref to if_ixml,
          l_text      type ref to if_ixml_text,
          ls_srctab1  type xstring,
          l_retcode type sysubrc.    "#EC *.
    create object lo_mxml.
    move 'cxml SYSTEM "http://b2b.xxxxx.com/"' to l_string.
    class cl_ixml definition load.
    g_ixml = cl_ixml=>create( ).
    m_document = g_ixml->create_document( ).
      call method m_document->create_document_type
        exporting
           name   = 'cXML'
        receiving
          rval   = m_doctype.
    call method m_document->set_document_type
        exporting
          document_type = m_doctype.
      l_dom = m_document->create_element( name = 'cXML' ).
      l_retcode = m_document->append_child( l_dom ).
      move gw_respond-payload_id to l_string.
    *____setting attribute payload id for cxml tag
      call method l_dom->set_attribute
        exporting
          name    = 'payloadID'
          value   = l_string
         NODE    = LO_NODE
        receiving
          rval = l_retcode.
    call method lo_mxml->display.
    cheers,
    sasi

  • Better way to sort multi dim int array

    I'm tracking key value pairs of ints. I know that the keys will not repeat. I've decided to do this in an int[][] array
    int[][] data = new int[2][many millions]This app crunches a lot of data so I'm shooting for the best memory handling. I push a bunch of key - value pairs into the array. I will likely populate many if not all data and not have to search until I'm done populating so I'm not sorting as I go.
    I know that I can sort the single dim array data[0] but how can I keep the values array data[1] synchronized? I've tried a few things, all have been successful but I'm wondering if there's a better method. Currently I create copy arrays for the keys and values, sort the original keys, and loop through the copy keys. For each copy key I binary search the sorted keys and drop the value in the correct spot. I don't like having to allocate 2X the amount of memory for the swap arrays. Any thoughts?
    Thanks
    ST

    Jos, thanks for the reply. I tried this method but I don't get as much
    storage since each internal array counts as an object.Yes I know; maybe I've got something for you, waidaminnit <dig-dig/>
    <shuffle-shuffle/> Ah, got it. Suppose you wrap your two dim array in
    a simple class that implements this interface:public interface Sortable {
         public int length();
         public int compare(int i, int j);
         public void swap(int i, int j);
    }I think the semantics of the methods are obvious. Given this interface
    you can sort anything you like using this thingy:public class HeapSort {
         private Sortable s;
         private void heapify(int i, int n) {
              for (int r, l= (i<<1)+1; l < n; i= l, l= (i<<1)+1) {
                   if ((r= l+1) < n && s.compare(l, r) < 0) l= r;
                   if (s.compare(i, l) < 0) s.swap(i, l);
         private void phase1() {
              for (int n= s.length(), i= n/2; i >= 0; i--)
                   heapify(i, n);
         private void phase2() {
              for (int n= s.length(); --n > 0; ) {
                   s.swap(0, n);
                   heapify(0, n);
         public HeapSort(Sortable s) { this.s= s; }
         public Sortable sort() {
              phase1();
              phase2();
              return s;
    }kind regards,
    Jos

  • Sorting 2D string array

    Hi I am new to labview. I want to sort my 2D string array by col 1. But I dont know how to sort it perfectly. My sorted array will be something like this.
    Col 1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    A11

    duplicate, see: http://forums.ni.com/ni/board/message?board.id=170&thread.id=317581&jump=true
    LabVIEW Champion . Do more with less code and in less time .

  • Newbie trying to sort 2D string array

    Dear all,
    After read some book chapters, web sites including this, I still don't get the point.
    If I have a file like,
    1 aaa 213 0.9
    3 cbb 514 0.1
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    and I load into memory as a String[][]
    here comes the problem, I sort by column 1 (aaa,...,bba) using an adaptation of the Quicksort algorithm for 2D arrays
    * Sort for a 2D String array
    * @param a an String 2D array
    * @param column column to be sort
    public static void sort(String[][] a, int column) throws Exception {
    QuickSort(a, 0, a.length - 1, column);
    /** Sort elements using QuickSort algorithm
    static void QuickSort(String[][] a, int lo0, int hi0, int column) throws Exception {
    int lo = lo0;
    int hi = hi0;
    int mid;
    String mitad;
    if ( hi0 > lo0) {
    /* Arbitrarily establishing partition element as the midpoint of
    * the array.
    mid = ( lo0 + hi0 ) / 2 ;
    mitad = a[mid][column];
    // loop through the array until indices cross
    while( lo <= hi ) {
    /* find the first element that is greater than or equal to
    * the partition element starting from the left Index.
    while( ( lo < hi0 ) && ( a[lo][column].compareTo(mitad)<0))
    ++lo;
    /* find an element that is smaller than or equal to
    * the partition element starting from the right Index.
    while( ( hi > lo0 ) && ( a[hi][column].compareTo(mitad)>0))
    --hi;
    // if the indexes have not crossed, swap
    if( lo <= hi )
    swap(a, lo, hi);
    ++lo;
    --hi;
    /* If the right index has not reached the left side of array
    * must now sort the left partition.
    if( lo0 < hi )
    QuickSort( a, lo0, hi, column );
    /* If the left index has not reached the right side of array
    * must now sort the right partition.
    if( lo < hi0 )
    QuickSort( a, lo, hi0, column );
    * swap 2D String column
    private static void swap(String[][] array, int k1, int k2){
    String[] temp = array[k1];
    array[k1] = array[k2];
    array[k2] = temp;
    ----- end of the code --------
    if I call this from the main module like this
    import MyUtil.*;
    public class kaka
    public static void main(String[] args) throws Exception
    String[][]a = MyUtil.fileToArray("array.txt");
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,1);
    MyMatrix.printf(a);
    System.out.println("");
    MyMatrix.sort(a,3);
    MyMatrix.printf(a);
    for the first sorting I get
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bba 111 7.1
    9 bbc 417 10.4
    3 cbb 514 0.1
    8 dee 887 2.1
    (lexicographic)
    but for the second one (column 3) I get
    3 cbb 514 0.1
    1 aaa 213 0.9
    2 abc 219 1.3
    9 bbc 417 10.4
    8 dee 887 2.1
    9 bba 111 7.1
    this is not the order I want to apply to this sorting, I would like to create my own one. but or I can't or I don't know how to use a comparator on this case.
    I don't know if I am rediscovering the wheel with my (Sort String[][], but I think that has be an easy way to sort arrays of arrays better than this one.
    I've been trying to understand the Question of the week 106 (http://developer.java.sun.com/developer/qow/archive/106/) that sounds similar, and perfect for my case. But I don't know how to pass my arrays values to the class Fred().
    Any help will be deeply appreciated
    Thanks for your help and your attention
    Pedro

    public class StringArrayComparator implements Comparator {
      int sortColumn = 0;
      public int setSortColumn(c) { sortColumn = c; }
      public int compareTo(Object o1, Object o2) {
        if (o1 == null && o2 == null)
          return 0;
        if (o1 == null)
          return -1;
        if (o2 == null)
          return 1;
        String[] s1 = (String[])o1;
        String[] s2 = (String[])o2;
        // I assume the elements at position sortColumn is
        // not null nor out of bounds.
        return s1[sortColumn].compareTo(s2[sortColumn]);
    // Then you can use this to sort the 2D array:
    Comparator comparator = new StringArrayComparator();
    comparator.setSortColumn(0); // sort by first column
    String[][] array = ...
    Arrays.sort(array, comparator);I haven't tested the code, so there might be some compiler errors, or an error in the logic.

  • Sort String Array by Date

    I use the following code to populate a string array:
    File dirFile          = new File("C:\\somedir");
    String fileImport[]      = dirFile.list();
    This gives me a string array with a whole bunch of files in the following format:
    XXXDDMMYYHHMISS.xml
    What I need to know is what is the easiest way to sort this array based on this date format, or any date format, in the ascending order, so that when I am loading my XML files, I get the oldest one first.
    Appreciate any input.
    Sam

    Use the String name of the file (the Date part), together with a java.text.SimpleDateFormat object to parse() the String. You have to set the formatter with a pattern - these are explained fully in the Javadocs for the SimpleDateFormat class. After parsing, you will have java.util.Date objects for each of the files - you can then use these as keys in a java.util.SortedMap (the values would be the files) - the natural ordering of dates will ensure that they are ordered appropriately

  • Looking for a simple way to convert a string to title case

    New to LiveCycle and Javascript.  Looking for a simple way to convert a string to title case, except acronyms.  Currently using the the following, it converts acronyms to lower case:
    var str  =  this.rawValue;
    var upCase = str.split(" ");
    for(i=0; i < upCase.length; i++) {
    upCase[i] = upCase[i].substr(0,1).toUpperCase() + upCase[i].substr(1).toLowerCase();
    this.rawValue = upCase.join(' ');

    Thanks for the reply.
    Found the following script in a forum, which works fine as a "custom validation script" in the.pdf version of my form.  However, it will not work in LiveCycle?  The problem seems to be with
    "return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g"
    function toTitleCase(str) {
    var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
        return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
    if (index > 0 && index + match.length !== title.length &&
      match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
    (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
    title.charAt(index - 1).search(/[^\s-]/) < 0) {
    return match.toLowerCase();
    if (match.substr(1).search(/[A-Z]|\../) > -1) {
      return match;
      return match.charAt(0).toUpperCase() + match.substr(1);
    event.value = toTitleCase(event.value);

  • String Array Sorting

    Question 1. Anybody know how to easily sort a string array?
    Question 2. Is there any good data base management VI's out there anywhere?
    Thank you

    > Question 1. Anybody know how to easily sort a string array?
    >
    There is this icon in the Array palette called Sort 1D Array. You might want
    to give it a try.
    > Question 2. Is there any good data base management VI's out there anywhere?
    >
    There may be some freebie stuff floating around, but I know that NI has
    an SQL add-on for communicating with most standard databases. As mentioned
    in a previous posting this morning, you can also use ActiveX if that is
    more convenient/easier for you. From my experience, most people find the
    SQL approach easier once they get past the three letter acronym.
    Greg McKaskle

  • Is there an easy way to replace individual elements in one string array from another striing array?

    I have a string array with elements as follows:
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 5E 00 00 00
       00 00 50 00 30 00 33 00
       34 00 39 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
    The array I want to use to replace values with is:
    43 4E 31 30 30 33 30 30 31 41
    Where 43 goes in the 3rd row fifth position
    Where 4E goes in the 3rd row seventh position
    Where 31 goes in the 4th row  first position
    Where 30 goes in the 4th row third position
    Where 30 goes in the 4th row fifth position
    Where 33 goes in the 4th row seventh position
    Where 30 goes in the 5th row  first position
    Where 30 goes in the 5th row third position
    Where 31 goes in the 5th row fifth position
    Where 41 goes in the 5th row seventh position
    So the final array looks as follows:
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 43 00 4E 00
       31 00 30 00 30 00 33 00
       30 00 30 00 31 00 41 00
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
    Is there an easy way to replace an element of a string within an array with another element of a string within a different array?
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_Add_SCAN_SN_2_PAT_DATA (temp).vi ‏13 KB

    Try this
    Omar
    Message Edited by Omar II on 03-24-2010 03:25 PM
    Omar
    Attachments:
    CMM_Add_SCAN_SN_2_PAT_DATA%20(temp)[1].vi ‏17 KB

  • Best Way to Enumerate a non-unique Array of String to Integers

    Hello,
    I am trying to find the best way to enumerate an array of strings to integers. This string array is thousands in number and contains non-unique values.
    I also don't know before run-time what those values are, so I have to dynamically determine the enumeration.
    For example a user reads in an array of colors (but we didnt know this before runtime) of "red", "green", "red", "blue", "white", "green", "black", "blue"
    I would like this to enumerate to 0, 1, 0, 2, 3, 1, 4, 2
    as zero based enumeration.
    Is there any suggested methods of doing this as efficiently on SPEED over MEMORY as possible?
    Thanks!
    Glenn

    I also don't know before run-time what those values are, so I have to dynamically determine the enumeration.Are you saying that you can't pre-define the universe of colors that a user could potentially enter? If so, how will you determine the equivalence of RED to 0, etc? That sounds suspicious, there is a finite number of colors!
    Anyway, for what it's worth, here's some code (that requires you know the color labels that could be entered.)
    enum Color
        RED(0), GREEN(1), BLUE(2), BLACK(3), WHITE(4);
        private final int colorValue;
        private Color(int colorValue)
            this.colorValue = colorValue;
        public int getColorValue()
            return colorValue;
    public class EnumTest
        public static void main(String[] args)
            System.out.println(Color.RED + " = " + Color.RED.getColorValue());
            System.out.println(Color.GREEN + " = " + Color.GREEN.getColorValue());
            System.out.println(Color.BLUE + " = " + Color.BLUE.getColorValue());
            System.out.println(Color.BLACK + " = " + Color.BLACK.getColorValue());
            System.out.println(Color.WHITE + " = " + Color.WHITE.getColorValue());
    }

  • SIMPLE QUESTION! converting an Enumeration to a String array;

    Enumeration e=request.getParameterNames();
    i have an enumeration that contains some String objects
    how can i convert it to a String array?
    thanks a lot.

    String str = null;
    List list = new ArrayList();
    while(e.hasMoreElements()) {
         str = (String)e.nextElement();
         list.add(str);
    String[] strArray = (String[]) list.toArray();
    Disclaimer: Code not tested; use at your own
    risk ;)Taht piece of code will probably throw class cast exception at the line:
    String[] strArray = (String[]) list.toArray();The array returned is an object array. You should use:
    String[] strArray = (String[]) list.toArray(new String[list.size()]);That methods returns an array of the same type as the argument.
    /Kaj

  • String Array Constant Addition

    Is there an elegant way of marking the last element in a string array
    constant? i.e. I take an Array constant, and add a simple string to it,
    so that it becomes a String Array Constant. Now I add elements 1 and 2
    and 3. But now I want to take element 3 out. If I just delete Element 3
    contents from the string control, that is fine, but the # of Array
    elements is still 3. It is just that the 3rd elelment is null. How can I
    make the array length 2? Now I know that starting over is one option
    (just creat a new array constant, and add the two elements) but what if
    my array constant has 100 elements and I want to make it 99. I also
    know that programatically I can remove these elelents, but I am taking
    about in the programming of th
    is constant. I must be over looking
    something... Any ideas???
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    [email protected] wrote:
    > Is there an elegant way of marking the last element in a string array
    > constant? i.e. I take an Array constant, and add a simple string to it,
    > so that it becomes a String Array Constant
    Arrays must be all the same type. If the last element is a constant, all
    elements are
    > Now I add elements 1 and 2
    > and 3. But now I want to take element 3 out. If I just delete Element 3
    > contents from the string control, that is fine, but the # of Array
    > elements is still 3. It is just that the 3rd elelment is null.
    In a string, yes, Empty strings are essentially nulls.
    > How can I
    > make the array length 2? Now I know that starting over is one option
    > (just creat a new array constant, and add the two elements) but what if
    > my array cons
    tant has 100 elements and I want to make it 99. I also
    > know that programatically I can remove these elelents, but I am taking
    > about in the programming of this constant. I must be over looking
    > something... Any ideas???
    This is one of my problems. It is easy to size an array up, but hard to size
    down.
    Of course you can resize at run time but the only way I know to do this
    when editing is to start over.
    Kevin Kent
    Attachments:
    Kevin.Kent.vcf ‏1 KB

  • 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

  • Sort two one dimensional arrays

    I am having trouble sorting two one dimensional arrays. The first array is int type with ID numbers. I use a bubble sort to sort those. The other array is a string array of video titles. When the first int type array of ID numbers sort, I want the second string type array to follow it. I have tried many things and I can not get it to work properly. Here is what I have for now without the string sort. Can someone help me?
    public class Video
         public static void main(String[] args)
         int[] numID = {168, 397, 102, 39, 239};
         String[] videoTitle = {"Godzilla", "Superman", "Hannibal", "Star Wars", "Men In Black"};
         System.out.println("Here are your selections:");
         System.out.println();
    System.out.print(numID[0]);
         System.out.println("\t" +videoTitle[0]);
         System.out.print(numID[1]);
         System.out.println("\t" +videoTitle[1]);
         System.out.print(numID[2]);
         System.out.println("\t" +videoTitle[2]);
         System.out.print(numID[3]);
         System.out.println("\t" +videoTitle[3]);
         System.out.print(numID[4]);
         System.out.println("\t" +videoTitle[4]);
         System.out.println();
    System.out.println();
    //Sorting ID numbers in ascending order
         int a;
         int b;
         int temp;
    for (a = 0; a < (numID.length - 1); ++a)
         for(b = 0; b < (numID.length - 1); ++b)
              if(numID[b] > numID[b + 1])
                             temp = numID;
                             numID[b] = numID[b + 1];
                             numID[b + 1] = temp;
              System.out.println("Here are your selections in ascending order:");
              System.out.println();
         System.out.print(numID[0]);
              System.out.println("\t" +videoTitle[0]);
              System.out.print(numID[1]);
              System.out.println("\t" +videoTitle[1]);
              System.out.print(numID[2]);
              System.out.println("\t" +videoTitle[2]);
              System.out.print(numID[3]);
              System.out.println("\t" +videoTitle[3]);
              System.out.print(numID[4]);
              System.out.println("\t" +videoTitle[4]);
              System.out.println();
         System.out.println();

    There are ways to do that, of which the simplest would be to switch entries in both arrays at the same time. But since Java is an object-oriented language, the better way to do it would be to make a Video object containing a number and a title, put those objects in an array, and sort the objects.

Maybe you are looking for

  • Freight -Group conditon not getting Reflected at an item level in Delivery.

    Hi SAP Gurus !, I want to draw your kind attention towards my problem. 1.  I had created a delivery with a header freight conditon type ZF00,the same conditon was getting reflected in all the item,But   after sometime i deleted that condition from he

  • Oracle linux install dies

    Hi all, I'm installing Oracle 8.0.5.1 on Redhat 6.1 (with updates from the updater service) and am running into a problem during the intall script. It seems to get most of the way thru the install and then blows up, same place always. It's when the s

  • UTL_FILE Overwrites Data

    Guys, I am trying to write multiple files with multiple lines in each file. These files will be named with ID grabbed from cursor(Cursor 1 in code). This code does write multiple files and names the file name correctly. The only problem is in each fi

  • A hperlink for a header file in a c/c++ project

    Hi, How can I configure a c/c++ project, so that the #include directive will be followed by a header file name with a hyperlinlk (so that clicking on it will cause the editor to jump to that header file ? ) Mark

  • What widget is used for this Site-of-the-Day?

    My Muse website is for my design business, and I need to show several pages of design samples (covers, logos, tech art, etc.). I think a slideshow widget will work best, but I have problems with the built-in ones (another forum entry probably). I lik