You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Normal wayif(this.orderBy){results=this.order==='asc' ?
results[0].sort((a,b)=>(a[this.orderBy]>b[this.orderBy]) ? 1 : -1):
results[0].sort((a,b)=>(a[this.orderBy]<b[this.orderBy]) ? 1 : -1);}// Better wayconstinversionFactor=this.order==='asc' ? 1 : -1;results=results[0].sort((a,b)=>a[this.orderBy]<b[this.orderBy] : -1*inversionFactor : 1*inversionFactor);// this is a reusable function and can go outside of other functionsconstcompareBy=(prop,invert)=>(a,b)=>{if(a[prop]===b[prop]){return0;}return(a[prop]<b[prop] ? -1 : 1)*(invert ? -1 : 1);};results=results[0].sort(compareBy(this.orderBy,this.order==='desc'));