VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-sorteduniqby-method/

⇱ Lodash _.sortedUniqBy() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.sortedUniqBy() Method

Last Updated : 15 Jul, 2025

Lodash _.sortedUniqBy method is used to return the lowest index of the array where an element can be inserted and maintain its sorted order. Also, this method is like _.uniqBy except that it's designed and optimized for sorted arrays.

Syntax:

_.sortedUniqBy(array, [iteratee]);

Parameters:

  • array: This parameter holds the array to inspect.
  • [iteratee=_.identity] (Function): This parameter holds the iteratee invoked per element.

Return Value:

This method is used to return the new duplicate free array.

Example 1: In this example, we are getting an array that has unique elements by the use of the lodash _.sortedUniqBy() method.

Output:

[1.1, 2.1, 3.5]

Example 2: In this example, we are getting an array that has unique elements by the use of the lodash _.sortedUniqBy() method.

Output:

[112.1, 112.1, 132.5]

Note: This will not work in normal JavaScript because it requires the library lodash to be installed.

Comment