array ( 'id' => 70, 'nome' => 'ALYSON GOMES DA SILVA BRITO', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 1 => array ( 'id' => 73, 'nome' => 'DAVID LUCAS DE ABREU SANTANA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 2 => array ( 'id' => 75, 'nome' => 'JHON LENN ANDRADE DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 3 => array ( 'id' => 84, 'nome' => 'LARISSA MANOELA GUIMARAES CARDOSO', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => true, ), 4 => array ( 'id' => 89, 'nome' => 'JOAO PEDRO CARDOSO DE CARVALHO', 'is_social_benefit' => false, 'is_pcd' => true, 'is_nearby' => false, 'has_siblings' => false, ), 5 => array ( 'id' => 91, 'nome' => 'MATHEUS DA SILVA MATOS', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 6 => array ( 'id' => 100, 'nome' => 'JOÃO LUCAS FREITAS FERNANDES', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 7 => array ( 'id' => 102, 'nome' => 'ENZO GABRIEL RIBEIRO CARDOSO', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => true, ), 8 => array ( 'id' => 103, 'nome' => 'ISAQUE DANIEL GONÇALVES DA SILVA GOMES', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 9 => array ( 'id' => 105, 'nome' => 'PEDRO LUCAS BARBOSA DOS SANTOS', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 10 => array ( 'id' => 114, 'nome' => 'FERNANDO GONÇALVES VIEIRA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 11 => array ( 'id' => 117, 'nome' => 'MURILO RIOS GOMES', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 12 => array ( 'id' => 121, 'nome' => 'HENZO OLIVEIRA DA SILVA', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 13 => array ( 'id' => 129, 'nome' => 'RYANE SOPHIA DA SILVA FERREIRA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 14 => array ( 'id' => 147, 'nome' => 'PEDRO LUCCA RODRIGUES DA SILVA', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 15 => array ( 'id' => 155, 'nome' => 'JOAQUIM RIBEIRO DE ALMEIDA COELHO', 'is_social_benefit' => false, 'is_pcd' => true, 'is_nearby' => false, 'has_siblings' => false, ), 16 => array ( 'id' => 160, 'nome' => 'BIANCA DE SOUZA FERREIRA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 17 => array ( 'id' => 167, 'nome' => 'JOÃO MIGUEL GOMES DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 18 => array ( 'id' => 176, 'nome' => 'LEONARDO DA SILVA DE JESUS', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 19 => array ( 'id' => 178, 'nome' => 'ENZO GONÇALVES PIMENTA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 20 => array ( 'id' => 182, 'nome' => 'BERNARDO GABRIEL FERREIRA DA SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 21 => array ( 'id' => 198, 'nome' => 'VÍVIAN ROCHA DOS SANTOS', 'is_social_benefit' => false, 'is_pcd' => true, 'is_nearby' => false, 'has_siblings' => false, ), 22 => array ( 'id' => 200, 'nome' => 'KEVEN GONÇALVES DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 23 => array ( 'id' => 206, 'nome' => 'MATHEUS BARBOSA DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 24 => array ( 'id' => 211, 'nome' => 'KEZIA BEATRIZ GOMES DE SANTANA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 25 => array ( 'id' => 220, 'nome' => 'NICKOLAS EDUARDO CARDOSO DOS SANTOS', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 26 => array ( 'id' => 224, 'nome' => 'ALICE DOS SANTOS SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 27 => array ( 'id' => 227, 'nome' => 'MARYANE DE AQUINO ALMEIDA', 'is_social_benefit' => true, 'is_pcd' => true, 'is_nearby' => false, 'has_siblings' => false, ), 28 => array ( 'id' => 230, 'nome' => 'GABRIEL FERREIRA SANTANA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 29 => array ( 'id' => 231, 'nome' => 'DANIEL CARDOSO DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 30 => array ( 'id' => 233, 'nome' => 'ENZO GABRIEL BARBOSA DE ABREU', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 31 => array ( 'id' => 242, 'nome' => 'MILENA KARIANY DA SILVA NASCIMENTO', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => true, ), 32 => array ( 'id' => 245, 'nome' => 'KETYLLEN KAWANY NUNES SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 33 => array ( 'id' => 246, 'nome' => 'PÂMELLA FERREIRA GONÇALVES', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 34 => array ( 'id' => 247, 'nome' => 'RUAN BARBOSA DE JESUS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 35 => array ( 'id' => 252, 'nome' => 'MÁRIO PEDRO CORDEIRO DA SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 36 => array ( 'id' => 253, 'nome' => 'ANGELINO JOSÉ CARDOSO DA SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => true, ), 37 => array ( 'id' => 255, 'nome' => 'STEFANNY ANIELE GONCALVES DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 38 => array ( 'id' => 261, 'nome' => 'JOÃO GABRIEL SOUZA MATOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 39 => array ( 'id' => 265, 'nome' => 'VICTORIA SOPHIA RIBEIRO DANTAS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 40 => array ( 'id' => 269, 'nome' => 'VICTOR MIGUEL GOMES VILELA', 'is_social_benefit' => false, 'is_pcd' => true, 'is_nearby' => false, 'has_siblings' => false, ), 41 => array ( 'id' => 272, 'nome' => 'MARIA CLARA DANTAS E SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 42 => array ( 'id' => 276, 'nome' => 'PEDRO LUCAS DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 43 => array ( 'id' => 277, 'nome' => 'GABRIEL ALVES DA SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 44 => array ( 'id' => 280, 'nome' => 'MISAEL ARAÚJO CRUZ', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 45 => array ( 'id' => 282, 'nome' => 'RYAN RIBEIRO SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 46 => array ( 'id' => 283, 'nome' => 'RIVALDO JOSÉ OLIVEIRA SILVA SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => true, ), 47 => array ( 'id' => 286, 'nome' => 'ROBERTA BARBOSA GONÇALVES', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => true, ), 48 => array ( 'id' => 289, 'nome' => 'ANNA JÚLIA MACEDO BARBOSA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 49 => array ( 'id' => 293, 'nome' => 'SAMUEL DA SILVA PEREIRA', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 50 => array ( 'id' => 297, 'nome' => 'MYLENA OLIVEIRA GONÇALVES', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => true, ), 51 => array ( 'id' => 302, 'nome' => 'LEVY ENZO DOS SANTOS', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 52 => array ( 'id' => 306, 'nome' => 'LÍVIA LOIOLA DE SOUZA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 53 => array ( 'id' => 309, 'nome' => 'JOÃO MIGUEL DE ANDRADE SANTANA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 54 => array ( 'id' => 310, 'nome' => 'EMILY OLIVIA MACEDO ALVES DAS NEVES', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 55 => array ( 'id' => 312, 'nome' => 'LUIZ MIGUEL COELHO ARAÚJO', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 56 => array ( 'id' => 313, 'nome' => 'ANA CRISTINA DA CONCEIÇÃO LIMA', 'is_social_benefit' => false, 'is_pcd' => false, 'is_nearby' => true, 'has_siblings' => false, ), 57 => array ( 'id' => 316, 'nome' => 'ALICE ALVES NEVES', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), 58 => array ( 'id' => 320, 'nome' => 'MAYSA CORDEIRO DA SILVA', 'is_social_benefit' => true, 'is_pcd' => false, 'is_nearby' => false, 'has_siblings' => false, ), ); function fisherYatesShuffle(array $items, $groupSeed) { $n = count($items); if ($n <= 1) return $items; $hashedSeed = hash('sha256', $groupSeed); for ($i = $n - 1; $i > 0; $i--) { $hash = hash_hmac('sha256', $i . $hashedSeed, $hashedSeed); $j = hexdec(substr($hash, 0, 8)) % ($i + 1); $temp = $items[$i]; $items[$i] = $items[$j]; $items[$j] = $temp; } return $items; } // SEPARAÇÃO DOS GRUPOS (IGUAL AO NOVO LOTTERYSERVICE) $g1 = []; $g2 = []; $g3 = []; $g4 = []; $g5 = []; foreach ($candidatos as $c) { // ALTERADO: PCD passa a ser a primeira verificação (Prioridade 1) if ($c['is_pcd']) { $g1[] = $c; } // ALTERADO: Social passa a ser a segunda verificação (Prioridade 2) elseif ($c['is_social_benefit']) { $g2[] = $c; } elseif ($c['is_nearby']) { $g3[] = $c; } elseif ($c['has_siblings']) { $g4[] = $c; } else { $g5[] = $c; } } echo "--- PROCESSANDO SORTEIO POR PRIORIDADES (NOVA HIERARQUIA) ---\n"; echo "G1: PCD | G2: SOCIAL | G3: PROXIMIDADE | G4: IRMÃOS | G5: AMPLA\n\n"; $r1 = fisherYatesShuffle($g1, $sementeBase . '_g1'); $r2 = fisherYatesShuffle($g2, $sementeBase . '_g2'); $r3 = fisherYatesShuffle($g3, $sementeBase . '_g3'); $r4 = fisherYatesShuffle($g4, $sementeBase . '_g4'); $r5 = fisherYatesShuffle($g5, $sementeBase . '_g5'); $resultadoFinal = array_merge($r1, $r2, $r3, $r4, $r5); echo "LISTA FINAL AUDITADA:\n"; foreach ($resultadoFinal as $index => $c) { echo sprintf("%03dº | %-30s | ID: %d\n", $index + 1, $c['nome'], $c['id']); }