解決js sort()的排序問題

var s=[ 0, 1, 5, 10, 15, 6]; function compare( value1, value2){ if( value1< value2){ return - 1; } else if( value1> value2){ return 1; } else{ return 0; } } s. sort( compare); console. log( s)
相關文章
相關標籤/搜索