JavaScript_中的坑 sort
JavaScript_中的坑 sort
01) 排序 sort
[3,15,8,29,102,22].sort((a,b)=>{ return a-b}); // 结果 [3, 8, 15, 22, 29, 102] [3,15,8,29,102,22].sort(); // 结果 [102, 15, 22, 29, 3, 8] ['a_3','a_15','a_8','a_29','a_102','a_22'].sort(); // 结果 ["a_102", "a_15", "a_22", "a_29", "a_3", "a_8"]