How to sort the date column according to month in a table using javascript?
<p>How to convert date dd mon yyyy to mon dd format in javascript?
I have created a table using javascript. The table contain date column in format dd mon yyyy. I want to convert that format to dd mon and sort it according  to month. what to do? plz help me.</p>

<p>Here is my code...</p>

<pre><code>&lt;script&gt;

var now = new Date();

now.format("dd mmm");
var allNums = false;
var allDates = false;
var lastSort = -1;
var absOrder = true;

function setDataType(inValue) {


    var isDate = new Date(inValue);
    if (isDate == "NaN") {
        if (isNaN(inValue)){

            inValue =  inValue.toUpperCase();
            allNums = false
            allDates = false
            return inValue;
          }
        else {

            allDates = false
            return parseFloat(1*inValue);
          }
        }
  else {

        allNums = false
        return inValue ;
      }
  }

function sortTable(col){
    if (lastSort == col){

        absOrder ? absOrder = false : absOrder = true
    }
    else{
        absOrder = true
    }
    lastSort = col
    allTR = document.getElementById("dataTable").childNodes[0].childNodes

    totalRows = allTR.length
    colToSort = new Array()
    colArr = new Array()
    copyArr = new Array()
    resultArr = new Array()

    allNums = true
    allDates = true


    for (x=1; x &lt; totalRows; x++){
        colToSort[x-1] = setDataType(allTR[x].childNodes[col].innerText)
        colArr[x-1] = allTR[x]
    }

    for (x=0; x&lt;colToSort.length; x++){
        copyArr[x] = colToSort[x]
    }


    if (allNums){
        colToSort.sort(numberOrder)
    }
    else if (allDates){
        colToSort.sort(dateOrder)
    }
    else{
        colToSort.sort(textOrder)
    }


    for(x=0; x&lt;colToSort.length; x++){
        for(y=0; y&lt;copyArr.length; y++){
            if (colToSort[x] == copyArr[y]){
                boolListed = false

                for(z=0; z&lt;resultArr.length; z++){
                    if (resultArr[z]==y){
                        boolListed = true
                        break;
                    }
                }
                if (!boolListed){
                    resultArr[x] = y
                    break;
                }
            }
        }
    }

    for (x=0; x&lt;resultArr.length; x++){
        allTR[x+1].swapNode(colArr[resultArr[x]])
    }
}

function numberOrder(a,b){
    absOrder ? rVal = b - a : rVal = a - b
    return rVal
}

function dateOrder(a,b){
    absOrder ? rVal = Date.parse(a) - Date.parse(b) : rVal = Date.parse(b) - Date.parse(a)
    return rVal;
}

function textOrder(a,b){
    if (a.toString() &lt; b.toString()){
        absOrder ? rVal = -1 : rVal = 1
    }
    else{
        absOrder ? rVal = 1 : rVal = -1
    }
    return rVal
}
&lt;/script&gt;
&lt;body style="background-color:AliceBlue"&gt;
&lt;h1 style="color:Blue" align="center"&gt;&lt;div id="header" style="background-color:LightCyan;"&gt; Employee Birthday Information &lt;/div&gt;&lt;/h1&gt;

&lt;br/&gt;
&lt;br/&gt;

&lt;h&gt;&lt;b&gt; Sort by : &lt;/b&gt;&lt;/h&gt;

&lt;input type="radio"  onclick="sortTable(0)" name=sort&gt; Employee Id &lt;/input&gt;
&lt;input type="radio"  onclick="sortTable(1)" name=sort&gt; Employee Name &lt;/input&gt;
&lt;input type="radio"  onclick="sortTable(2)" name=sort&gt; Employee Birthdate &lt;/input&gt;

&lt;/br&gt;
&lt;/br&gt;
&lt;table id="dataTable"  align="center" cellpadding="10" cellspacing="10" bgcolor="LightCyan"&gt;
&lt;tr&gt;
&lt;th&gt;Employee Name&lt;/th&gt;
&lt;th&gt;Employee Id&lt;/th&gt;
&lt;th&gt;Employee Birthdate&lt;/th&gt;
&lt;/tr&gt;
&lt;td&gt; 1 &lt;/td&gt;
&lt;td&gt; Smita &lt;/td&gt;
&lt;td&gt; 4 Nov 1989&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; 26 &lt;/td&gt;
&lt;td&gt; Julie &lt;/td&gt;
&lt;td&gt; 29 Dec 1990 &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; 15 &lt;/td&gt;
&lt;td&gt; Rashmi &lt;/td&gt;
&lt;td&gt; 7 Mar 1987 &lt;/td&gt;
&lt;/tr&gt;
&lt;td&gt; 4 &lt;/td&gt;
&lt;td&gt; Jack &lt;/td&gt;
&lt;td&gt; 4 June 1986 &lt;/td&gt;
&lt;/tr&gt;
&lt;td&gt; 48 &lt;/td&gt;
&lt;td&gt; Soniya &lt;/td&gt;
&lt;td&gt; 3 July 1989 &lt;/td&gt;
&lt;/tr&gt;
&lt;td&gt; 32 &lt;/td&gt;
&lt;td&gt; John &lt;/td&gt;
&lt;td&gt; 3 June 1989 &lt;/td&gt;
&lt;/tr&gt;
&lt;td&gt; 45 &lt;/td&gt;
&lt;td&gt; Prajakta &lt;/td&gt;
&lt;td&gt; 9 Aug 1989 &lt;/td&gt;
&lt;/tr&gt;
&lt;td&gt; 7 &lt;/td&gt;
&lt;td&gt; Apeksha &lt;/td&gt;
&lt;td&gt; 6 Feb 1989 &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>
