Javascript Array sortDesc()

Description

Javascript Array sortDesc()

Array.prototype.sortDesc = function() {
  return this.sort(function(x, y){
    if(x < y) {
      return 1/* w w w . j a  v  a2s. c om*/
    } else if(y < x) {
      return -1
    } else {
      return 0
    }
  })
}



PreviousNext

Related