M
M
mrrangerr2020-04-13 14:40:38
JavaScript
mrrangerr, 2020-04-13 14:40:38

How to sort an array of arrays?

I have an array of elements that I received from an object, they are listed below, I need to sort the array in ascending order. Tell me which way to move, what to use

let result;
let firstFiveTickets;
    if (tickets !== undefined) {
        result = Object.keys(tickets).map(value => Object.values(tickets[value]));
        firstFiveTickets = result.slice(0, 5)
    } 
// tickets - это объект

[Aray(3), Array(3), Array(3), Array(3), Array(3)]

0: (3) [34225, "EK", Array(2)]
1: (3) [74322, "EK", Array(2)]
2: (3) [53769, "MH", Array(2)]
3: (3) [53281, "SU", Array(2)]
4: (3) [30178, "EK", Array(2)]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-04-13
@mrrangerr

sort the array in ascending order - ascending what, the first number in the array?

data = 

data.sort((a, b) => a[0] - b[0])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question