I'm making a calendar app and I'm trying to put two lists together and sort them by start time. Each index of the list has a structure inside with a start and end variable. I'm trying to move these indexes in order, with respect to the starting time variable.
Asked
Active
Viewed 43 times
1 Answers
0
Use the .sort()
method of Array
like this:
myArray.sort((elemA, elemB) => elemA.start - elemB.start)
Here are the docs: https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Array/sort

Rudolf Manusachi
- 2,311
- 2
- 19
- 25

Edwin Vargas
- 1,132
- 1
- 8
- 14