Multi Dimensional Array - Holidays and Date sorting

Discussion in 'Java' started by freonirons409, Mar 30, 2010.

  1. freonirons409

    freonirons409 New Member

    Joined:
    Mar 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have two arrays: one being a list of occasion dates, and the other being the name of the occasion and they are being pulled from tables. These dates and occasions match one another in that if the first item in Array A (dates) is "December 25 2010", then the first item in Array B is "Christmas".

    So I have my script to look at the Date array and convert each entry with the new.Date class and all of that works fine, but I need to sort those dates in order from the earliest to latest, and still have the correct Occasion display.

    As an example this is how my arrays are put together (the dates and occasions are just examples of how they would come through back from the query):

    var dates = ["December 25 2010","October 31 2010","February 14 2010","September 16 2010"];
    var arraydate=new Array();
    arraydate[0] = new Date(dates[0]);
    arraydate[1] = new Date(dates[1]);
    arraydate[2] = new Date(dates[2]);
    arraydate[3] = new Date(dates[3]);
    //taking only the first 4 dates

    var occasions = ["Christmas","Halloween","Valentine's Day","Birthday"];
    var occ_date_array = [[arraydate], [occasions]];

    So occ_date_array is my multidimensional array, and from here I have no idea what I need to do next. I know I need to sort them but am unsure of how to sort the dates so the Feb 14th would be first listed first with Dec 25th last, and at the same time reorder the Occasion names names to still correspond with it's respected date.

    Can anyone help?!

    Thanks!!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice