Array.prototype.sort

2021-12-16 16:26阅读 41
    Array.prototype.sort = () => {
         for(let i = 0; i < this.length; i++) {
             for(let j = i+1; j< this.length; j++)  {

                 if (this[i] > this[j]) {
                     let temp = this[i]
                     this[i] = this[j]
                     this[j] = temp
                  }
             }
         }
         return this
    }
标签
标签
标签