Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sorting an array based on certain element

Array.sort(function (x, y) {
                let a = x.name.toUpperCase(),
                    b = y.name.toUpperCase();
                return a == b ? 0 : a > b ? 1 : -1;
            }); // place the element of array to be sorted in place of x.name and y.name
 
PREVIOUS NEXT
Tagged: #sorting #array #based #element
ADD COMMENT
Topic
Name
9+3 =