I want to sort this record and my input array is a1 \[code\]var a1 = ["ap1","ap10","ap11","ap2","ap3","ap4","ap5","ap6","ap7","ap8","ap9"];\[/code\]out put should be like :\[code\]["ap1","ap2","ap3","ap4","ap5","ap6","ap7","ap8","ap9","ap10","ap11"];\[/code\]Here is the code,\[code\] var a1 = ["ap1","ap10","ap11","ap2","ap3","ap4","ap5","ap6","ap7","ap8","ap9"]; var a2 = a1.sort(function(a,b){ var charPart = [a.substring(0,1), b.substring(0,1)], numPart = [a.substring(1)*1, b.substring(1)*1]; if(charPart[0] < charPart[1]) return -1; else if(charPart[0] > charPart[1]) return 1; else{ //(charPart[0] == charPart[1]){ if(numPart[0] < numPart[1]) return -1; else if(numPart[0] > numPart[1]) return 1; return 0; } }); alert(a2.toString());\[/code\]