-4

This is the order I want my movies to be in

This is the code of how I sorted the favorites release_date :

 sort_movieDates = () => {
    let releases = this.state.favorites.map(favorites=>favorites.release_date)
    let newFavorites=this.state.favorites.release_date;
    releases.sort();
    console.log(releases)

}

What I want to do is that to compare the favorites release_date with the movie details in here . If the favorites release_date match then I want it to be added in that order. For example since Jurassic World: the Fallen Kingdom has the release_date of 2018-06-06, it will be #6 because that's where that release_date is in releases. So how do I do this?

rockwire
  • 95
  • 1
  • 9
  • 1
    You need to pass a function to `Array.prototype.sort()` in order to sort objects in a meaningful way – Luca Kiebel Jun 29 '18 at 17:23
  • 4
    It's very hard for us to create a working example of a solution when the data you give us is a picture. – Taplar Jun 29 '18 at 17:23
  • 1
    Possible duplicate of [How to sort a javascript array of objects by date](https://stackoverflow.com/questions/19430561/how-to-sort-a-javascript-array-of-objects-by-date) – Mark Jun 29 '18 at 17:37
  • Please look again, I changed the question a little – rockwire Jun 29 '18 at 18:07