Questo dovrebbe funzionare:
SELECT p.id
FROM post p
LEFT JOIN comment c ON c.post_id = p.id
GROUP BY p.id
ORDER BY COALESCE(GREATEST(p.created, MAX(c.created)), p.created) DESC
Se assumiamo che un commento sia sempre più recente del post, possiamo semplificare:
SELECT p.id
FROM post p
LEFT JOIN comment c ON c.post_id = p.id
GROUP BY p.id
ORDER BY COALESCE(MAX(c.created), p.created) DESC
La funzione COALESCE restituisce la data del commento più recente se esiste, altrimenti la data di creazione del post, garantendo l'ordinamento corretto anche per i post senza commenti.