Add includes/srs_queue.php
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user