--!native
--!nonstrict
--!optimize 2
-- Compiled with roblox-ts v2.3.0
local function binaryInsert(array, value, lessThan)
	local left = 0
	local right = #array - 1
	while left <= right do
		local middle = (left + right) // 2
		local leftValue = array[left + 1]
		local middleValue = array[middle + 1]
		local _result = lessThan
		if _result ~= nil then
			_result = _result(leftValue, middleValue)
		end
		local _condition = _result
		if _condition == nil then
			_condition = leftValue < middleValue
		end
		if _condition then
			right = middle - 1
		else
			left = middle + 1
		end
	end
	local _array = array
	local _left = left
	local _value = value
	table.insert(_array, _left + 1, _value)
end
return {
	binaryInsert = binaryInsert,
}
