ArraySort in #typescript
▻https://hackernoon.com/arraysort-in-typescript-5f3b10263b4a?source=rss----3a8144eabfe3---4
Array #sort in typescriptIn this article, we will see How we can sort #arrays in typescript in a typed mannerby the end of this article, you will knowHow array sort works in typescriptUse of readonly arraysort function return typecase sensitive sortingsComparer functionHow array sort works in typescriptLet us see how we can sort an array in typescript.Suppose we have an array arr mentioned below, and I want to sort it.arr = [’vue’,’angular’,’react’]The easiest way is the [].sort function.arr = [’vue’,’angular’,’react’] console.log(arr.sort()) //result //[’angular’,’react’,’vue’]Sort function return typeSo the surprising part is that the sort function has actually manipulated our original array. It does not (...)