title: How to sort dates with moment.js in array as descending order
body: <p>Trying to make pagination,</p>
  
  <p>I have an array like below so</p>
  
  <p><a href="https://i.stack.imgur.com/L81H2.png" rel="nofollow noreferrer">https://drive.google.com/open?id=1iNsIKZs8IyZbm8M1N77PAkTjqSqFugKo</a></p>
  
  <p>In the array, there is createdAt object about time when created formatted by moment.js</p>
  
  <p>which I wanna sort as descending order so that newest posts coming up first</p>
  
  <p>postActions.js</p>
  
  <pre><code>firestore
    .collection("posts")
    .add({
      ...post,
      authorFirstName: profile.firstName,
      authorLastName: profile.lastName,
      authorId: authorId,
      createdAt: new Date()
    })
  </code></pre>
  
  <p>postReducer.js</p>
  
  <pre><code>case STORE_POSTS_SUCCESS:
    const snapshot = action.payload;
    const array = [];
    snapshot.forEach(doc =&gt; {
      //  console.log(doc);
      //  console.log(doc.id);
      array.push({
        id: doc.id,
        authorId: doc.data().authorId,
        authorFirstName: doc.data().authorFirstName,
        authorLastName: doc.data().authorLastName,
        title: doc.data().title,
        content: doc.data().content,
        createdAt: moment(doc.data().createdAt.toDate()).format(
          "MMMM Do YYYY, h:mm:ss a"
        )
      });
    });
  
    console.log(array);
    return {
      ...state,
      //  posts: array.slice(0)
      posts: array
    };
  </code></pre>