Like _.indexOf, except it performs a binary search on a sorted array. Returns the lowest matching index, or -1 when the value is absent. Part of Lodash Array since 4.0.0 (stable — not deprecated). Warning: the array must already be sorted ascending.
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.sortedIndexOf on an array. Start with this line.
Lodash
_.sortedIndexOf(array, value)
Call
What it does
_.sortedIndexOf(array, value)
Primary signature.
_.sortedIndexOf(array)
Call with an array argument.
Prefer import sortedIndexOf from "lodash/sortedIndexOf" when you want a smaller bundle.
Library declarations
Lodash
_.sortedIndexOf(array, value)
Parameters
Parameter
Description
array
Required. Sorted ascending collection to search
value
Required. Value to look up
Return Value
Return Value
Description
*
Lowest matching index, or -1
Lodash Examples
Example 1 — Official: Lowest Match Among Duplicates
_.sortedIndexOf is a Lodash 4.x Array helper (since 4.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines have indexOf / findIndex, but not this binary-search variant by name.
✓ Stable · Lodash 4.0.0+
_.sortedIndexOf()
Available in [email protected] full builds and the lodash/sortedIndexOf modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.sortedIndexOfLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import sortedIndexOf from "lodash/sortedIndexOf" for smaller builds. Not a native browser API — load Lodash first.
Frequently Asked Questions
_.sortedIndexOf(array, value) is like _.indexOf, but uses a binary search on a sorted ascending array. It returns the lowest index of a matching value, or -1 if the value is not present.
No. It is a read-only lookup. The array stays unchanged.
sortedIndex returns where to insert a value (always a valid insert index). sortedIndexOf returns where the value already is, or -1 if it is missing.
indexOf scans linearly and works on unsorted arrays. sortedIndexOf is faster on large sorted arrays (O(log n)) but requires ascending order.
SameValueZero — same family as indexOf: NaN matches NaN, and +0 matches -0.
Use import sortedIndexOf from "lodash/sortedIndexOf" or require("lodash/sortedIndexOf") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.sortedIndexOf.