Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type Comparator<T> = (a: T, b: T) => number
* @param insertValue value to be added to the array
* @param comparator function that helps determine where to insert the value (
*/
export function binaryInsert<T>(array: T[], insertValue: T, comparator: Comparator<T>) {
export function binaryInsert<T>(array: T[], insertValue: T, comparator: Comparator<T> = (a, b) => a < b ? -1 : 1) {
/*
* These two conditional statements are not required, but will avoid the
* while loop below, potentially speeding up the insert by a decent amount.
Expand Down