Javascript Array sortBy(comparator)

Description

Javascript Array sortBy(comparator)

Array.prototype.sortBy = function(comparator) {
    return this.sort((a,b) => {
        return comparator(a) < comparator(b) ? -1 : 1
    })/*w w  w  .  ja v a  2  s.co m*/
}



PreviousNext

Related