Sorting in Typescript (Simple Arrays & Array of Objects)
Hi Friends, This post is not regarding the SharePoint but it is a very common functionality that we need in day to day coding. So I thought to write down here. This functionality is of sorting in Typescript. Sorting simple Arrays Sorting is the very basic functionality that is required and when it comes to typescript we do get OOB method, but that is for the simple array. let fruits : string [] = [ ' Banana ' , ' Orange ' , ' Apple ' , ' Pineapple ' ] ; console . log (fruits. sort ()); Output : Apple, Banana, Orange, Pineapple Sorting an Array of Objects When it comes to sorting the array of objects, we do not have any OOB method which can serve our purpose. for this, we have to write our small custom logic within the sort method let fruits : any [] = [{ Name : ' Banana ' }, { Name : ' Orange ' }, { Name : ' Apple ' }, { Name : ' Pineapple ' }]; console . log (frui