一种算法实现机制。 (不能依赖 js toArray().sort(function(){}) )
访问量: 2080
今天遇到一种需求: 根据排名来拍, 0放在最下面。 有数字: 从小到大。
例如: [ 0 ,3, 1, 4, 0 ] => [ 1, 3, 4, 0, 0]
我怀疑使用 原生的 js toArray().sort() 排序是不行的。还得自己写。
更新:
看来是我的算法比较弱, 已经有大神写好了:
http://stackoverflow.com/questions/38006707/is-it-possible-to-sort-an-array-in-my-algorithm-using-the-raw-sort-method想起了当年大学师兄的话: 计算机说到底是数学。