Home » jQuery.uniqueSort() method

jQuery.uniqueSort() method

by Online Tutorials Library

jQuery.uniqueSort() method

The $.uniqueSort() method is used to sort an array of DOM elements and remove the duplicates. It returns the sorted array after removing the duplicates.

This method searches through the array of objects, sorts the array, and removes the duplicate nodes. The node which is exactly the same as the node already existing in the array is considered to be the duplicate node. If nodes are different, but their attributes are the same will not be considered duplicates.


This method accepts a single parameter which is defined as follows –

array: It is the array of DOM elements.


It is a simple example of using the $.uniqueSort() method. In this example, initially, there are two paragraph elements related to the para class. But we are using the .concat() method to create the duplicates of the paragraphs with class = “para”. So, the $.uniqueSort() method will remove the duplicates created using the .concat() method.

Test it Now


The output initially shows the 4 paragraph elements related to the class para, in which 2 are created using the .concat() method.

jQuery.uniqueSort() method

You may also like