Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Multi Dimensional Array - Holidays and Date sorting (http://www.go4expert.com/forums/multi-dimensional-array-holidays-date-t21593/)

freonirons409 31Mar2010 03:03

Multi Dimensional Array - Holidays and Date sorting
 
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!!!


All times are GMT +5.5. The time now is 13:48.