sorting array of arrays using one of their indexes

前端 未结 2 1887
再見小時候
再見小時候 2021-01-28 11:37

I have an array with different values in it and I\'d like to sort it by the numeric value in one of the indexes

const arr = [
  [\'foo\', var, 5],
  [\'fee\', v         


        
2条回答
  •  悲哀的现实
    2021-01-28 12:09

    function bubbleSort(arr){
       var len = arr.length;
       for (var i = len-1; i>=0; i--){
         for(var j = 1; j<=i; j++){
           if(arr[j-1]

    console.log out put is 9 7 5 4 3 2 Modify the code to loop through your object.var in Array

提交回复
热议问题