Like _.sortedIndex, but accepts an iteratee invoked for value and each element to compute their sort ranking (one argument: value). Part of Lodash Array since 4.0.0 (stable — not deprecated). Warning: the array must already be sorted ascending by that ranking.
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.sortedIndexBy on an array. Start with this line.
Mutate now. Only splice changes the array — not Lodash.
Sorted stay. Objects remain ordered by x.
Compatibility
Browser & Runtime Support
_.sortedIndexBy 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. There is no single native Array API with the same name.
✓ Stable · Lodash 4.0.0+
_.sortedIndexBy()
Available in [email protected] full builds and the lodash/sortedIndexBy 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
_.sortedIndexByLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import sortedIndexBy from "lodash/sortedIndexBy" for smaller builds. Not a native browser API — load Lodash first.
Frequently Asked Questions
_.sortedIndexBy(array, value, [iteratee=_.identity]) is like _.sortedIndex, but compares iteratee(value) against iteratee(each element). It returns the lowest index where value should be inserted to keep the array sorted by that ranking.
No. It only returns an insertion index. Use splice yourself if you want to insert the object.
The array must already be sorted ascending by the iteratee result — for example, objects sorted by o.x when you pass "x" or (o) => o.x.
sortedIndex compares elements directly (numbers, strings). sortedIndexBy projects each element through an iteratee first — ideal for arrays of objects.
Yes. Lodash invokes the same iteratee for value and for every array element so comparisons stay symmetric.
Use import sortedIndexBy from "lodash/sortedIndexBy" or require("lodash/sortedIndexBy") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.sortedIndexBy.