Javascript Array sortAsc()

Description

Javascript Array sortAsc()

Array.prototype.sortAsc = function() {
  return this.sort(function(x, y){
    if(x < y) {
      return -1/*from  w  ww.  java 2  s . c o  m*/
    } else if(y < x) {
      return 1
    } else {
      return 0
    }
  })
}



PreviousNext

Related