var yearArray = new Array(2009, 2009, 2010, 2010, 2009, 2010); // still sort the array yearArray.sort(); //$.unique(yearArray); yearArray = uniqueArray(yearArray);
function uniqueArray(a){ temp = new Array(); for(var i = 0; i < a.length; i ++){ if(!contains(temp, a[i])){ temp.length+=1; temp[temp.length-1] = a[i]; } } return temp; } function contains(a, e){ for(j=0;j<a.length;j++)if(a[j]==e)returntrue; returnfalse; }