createSortByBooleanFn
Creates a sort function for objects by a boolean property.
Values are coerced with Boolean() before comparing, so null, undefined,
0, and '' behave as false, and any other truthy value behaves as true.
Available since next
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
property | keyof T | The property to sort by. |
trueFirst | boolean | Whether true values sort before false values (default: true). |
Returns
Section titled “Returns”SortFn<T> — Sort function
Examples
Section titled “Examples”Sort objects with true values first
Section titled “Sort objects with true values first”Default items float to the top of the list.
Sort with false values first
Section titled “Sort with false values first”Pass trueFirst = false to invert the priority.
Related Types
Section titled “Related Types”SortFn
Section titled “SortFn”Sort function type for arrays
