How can I sort an indirect array with javascript?

前端 未结 4 1607
借酒劲吻你
借酒劲吻你 2020-12-10 22:42

In my project, I need to sort an array that contain index of an other array (it\'s item). I\'ve search for many hours, but I did not find anyone with my problem.

<         


        
4条回答
  •  醉梦人生
    2020-12-10 23:18

    Its much easy buddy use this arr.sort(function(a, b){return a - b}); // use return otherwise it will not triggered and - + plus denote ascndng dcndng ordee Simple method ..... Happy coding

提交回复
热议问题