-1

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.

enter image description here

hoangdv
  • 15,138
  • 4
  • 27
  • 48

1 Answers1

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