diff --git a/pkg/database/sql/media.go b/pkg/database/sql/media.go
index b13e267211958c82af7dafd03db2bd0b750cb5a4..16769bfc261774f6ac25ed4cf898917d5566232e 100644
--- a/pkg/database/sql/media.go
+++ b/pkg/database/sql/media.go
@@ -164,7 +164,8 @@ Model(&Media{}).
Offset(pagination.Page * pagination.Size).
Limit(pagination.Size).
Where("path like '" + pagination.Path + "%'").
- Order("created_at DESC").
+ Order("COALESCE (media_exifs.date_shot, media.created_at) DESC").
+ InnerJoins("INNER JOIN media_exifs ON media_exifs.media_id = media.id").
Find(&medias)
if result.Error != nil {