Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    Slightly changed version for sorting by multiple fields is here if needed: stackoverflow.com/questions/6913512/… Commented Dec 1, 2016 at 12:37
  • it looks like it could be the next one: export function generateSortFn( prop: string, reverse: boolean = false ): (...args: any) => number { return (a, b) => { return a[prop] < b[prop] ? reverse ? 1 : -1 : a[prop] > b[prop] ? reverse ? -1 : 1 : 0; }; } Commented May 23, 2020 at 4:29
  • agreed, but in some case i haven't got needs to look at utility functions. Commented May 25, 2020 at 2:00