Add includes/srs_queue.php

This commit is contained in:
2026-06-15 12:04:36 +02:00
parent 58721e681d
commit 7bea9b91a1
+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
function sortDueWords(array $words): array
{
$today = date('Y-m-d');
usort($words, function ($a, $b) use ($today) {
$aDue = $a['nextReview'] ?? '1970-01-01';
$bDue = $b['nextReview'] ?? '1970-01-01';
$aPriority = ($aDue <= $today) ? 0 : 1;
$bPriority = ($bDue <= $today) ? 0 : 1;
if ($aPriority !== $bPriority) {
return $aPriority <=> $bPriority;
}
return strcmp($aDue, $bDue);
});
return $words;
}