score:1

let docs = [{date: 1}, {date: 5}, {date: 2}]
const test = docs?.sort((a,b)=> a.date - b.date);
console.log(test);

score:1

const postCollection = collection(database, "posts");

const getPost = async () => {
    const data = await getDocs(query(postCollection, orderBy('date', 'desc')));
    const newData = data.docs.map((doc) => ({
        ...doc.data(),
        id: doc.id,
    }));
    
   setPostList(newData);
};

Related Query

More Query from same tag