JSFiddle - React, Tailwind, and code Playground
by Ishank Dubey
JavaScript
//alert(anArray);
//anArray.sort(function(a,b){
//alert(a.name +" " +b.name );
//return a.name.localeCompare(b.name);
//}
//);
//var i=0;
//for(i in anArray){
//console.log(anArray[i].name);
//}
//if(! (Array.ascending === 'function')){
Array.prototype.ascending = function(){
this.sort(function(a,b){
return a.name.localeCompare(b.name);
});
}
//}
var anArray = [{
name:"_ghi"
},{
name:"1ghi"
},{
name:"3abc"
}];
//console.log(anArray.ascending());