fix(dayplan): sort the trip's dates with an explicit compare

ISO dates sort the same as plain strings, but a sort without a compare
function reads as an accident to anyone checking it, and SonarCloud flags
it as one. The three places that order the trip's dates now say how.
This commit is contained in:
Maurice
2026-09-23 23:11:10 +02:00
parent 954758082b
commit c5ac479915
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -209,7 +209,7 @@ export class DayRemovalService {
*/
private renumber(tripId: number, rows: DayRow[], remaining: DayRow[]): string | null {
// ISO dates sort as plain strings.
const sortedDates = rows.map(r => r.date).filter((d): d is string => !!d).sort();
const sortedDates = rows.map(r => r.date).filter((d): d is string => !!d).sort((a, b) => a.localeCompare(b));
const setNumber = this.db.prepare('UPDATE days SET day_number = ? WHERE id = ?');
const setNumberAndDate = this.db.prepare('UPDATE days SET day_number = ?, date = ? WHERE id = ?');