0

i have multidimensional array with id number 1, 2, and 3. i want to sort it start with 1, 3 and last 2.

for now, i already sort it but only ascending sort.

this is example of my array:

array = ["Brent", "3", "1", "0", "33" , "0.1123"],["John", "2", "1", "1", "33" , "0.1443"],["Grace", "1", "1", "1", "33" , "0.1443"]]

here's my code:

function sortFunction(a, b) {
 if (a[1] === b[1]) {
    return 0;
     } else {
        return a[1] < b[1] ? -1 : 1;
     }
  }

i want result like this based on index[1]

array = [["Grace", "1", "1", "1", "33" , "0.1443"],["Brent", "3", "1", "0", "33" , "0.1123"],["John", "2", "1", "1", "33" , "0.1443"]]

how can i achieve this? any informations will help. thank you

0 Answers0