Like _.sortedLastIndex, but accepts an iteratee invoked for value and each element to compute their sort ranking (one argument: value). Returns the highest insert index (bisect right). 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 _.sortedLastIndexBy on an array. Start with this line.
Insert.splice(1, 0, row) writes after the equal ranking.
Mutate now. Only splice changes the array — not Lodash.
Sorted stay. Objects remain ordered by x.
Compatibility
Browser & Runtime Support
_.sortedLastIndexBy 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+
_.sortedLastIndexBy()
Available in [email protected] full builds and the lodash/sortedLastIndexBy 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
_.sortedLastIndexByLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import sortedLastIndexBy from "lodash/sortedLastIndexBy" for smaller builds. Not a native browser API — load Lodash first.
Frequently Asked Questions
_.sortedLastIndexBy(array, value, [iteratee=_.identity]) is like _.sortedLastIndex, but compares iteratee(value) against iteratee(each element). It returns the highest index where value should be inserted to keep the array sorted by that ranking.
sortedIndexBy is bisect left (lowest insert index). sortedLastIndexBy is bisect right (highest insert index). With equal rankings, they differ: before vs after the equal run.
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.
No. sortedLastIndexOf finds the last existing match (or -1). sortedLastIndexBy always returns an insert index in [0, length], even when the value is absent.
Use import sortedLastIndexBy from "lodash/sortedLastIndexBy" or require("lodash/sortedLastIndexBy") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.sortedLastIndexBy.