Import this in your client-side component
MyComponent.tsx
import { useSortObjByProperty } from "react-amazing-hooks";
API | Description | Type | Return Type | Example |
---|---|---|---|---|
arr | Array of objects to be sorted | Array<object> | void | Note* |
property | Name of the property to sort by | string | void | Note* |
order | Sorting order, either asc /true for ascending or desc /false for descending | `asc | desc | true |
useSortObjByProperty | Hook that sorts an array of objects based on a specified property | function | Array<object> | Note* |
sortedArray | Sorted array of objects | Array<object> | Array<object> | Note* |
Check the 'Example' tab above the table for an exhaustive example. *