请用js语言实现sort排序函数,要求:sort([4,5,2,-1,0])返回[-1,0,2,4,5]

         Array.prototype.sort1=function(fn){
             var len=this.length;
             while(len>0){
                 for(var i=0;i<len;i++){
                     var num=fn.call(null,this[i],this[i+1]);
                     if(num>0){
                         var temp=this[i];
                         this[i]=this[i+1];
                         this[i+1]=temp;
                     }
                 }
                 len--;
             }
         }
         var arr=[1,5,8,7,3,6];
         arr.sort1(function(a,b){
             return a-b;
         });
         console.log(arr);