workflows/labels: fix stale label date sorting

With the help of:
https://stackabuse.com/how-to-sort-an-array-by-date-in-javascript/

(cherry picked from commit c9257371dc)
This commit is contained in:
Wolfgang Walther
2025-06-25 09:44:33 +02:00
parent 2d017eece8
commit cb7dd7f255

View File

@@ -246,8 +246,8 @@ jobs:
'unmarked_as_duplicate',
].includes(event))
.map(({ created_at, updated_at, committer, submitted_at }) => new Date(updated_at ?? created_at ?? submitted_at ?? committer.date))
.sort()
.reverse()
// Reverse sort by date value. The default sort() sorts by string representation, which is bad for dates.
.sort((a,b) => b-a)
.at(0) ?? item.created_at
)