$json['id'] ?? basename($f, '.json'), 'ts' => $json['ts'] ?? filemtime($f)]; } } usort($list, function ($a, $b) {return ($b['ts'] ?? 0) <=> ($a['ts'] ?? 0);}); echo json_encode(['ok' => true, 'receipts' => $list], JSON_UNESCAPED_UNICODE);