<?php
"T3497012@CHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@BHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORA@BPHS@Bamz",
"T3497012@AHOSTBRHDDSB@EICM_BORB@BPHS@Aama",
"T3497012@AHOSTBRHDDSB@EICM_BORC@APHS@cama",
"T2497123@DHOSTBRHDDSB@CICM_BORD@APHS@camb",
"T2497123@EHOSTBRHDDSB@BICM_BORE@APHS@camc",
"T5557012@FHOSTBRHDDSB@AICM_BORF@APHS@camd"
);
$i = 1;
for ($i = 0; $i < (count($linhas) - 1); $i++){ $linhai = explode("@", $linhas[$i]); for ($j = $i + 1; $j < count($linhas); $j++){ $linhaj = explode("@", $linhas[$j]);
$troca = false;
if ($linhai[2] > $linhaj[2])
$troca = true;
else if (($linhai[2] == $linhaj[2]) && ($linhai[3] > $linhaj[3]))
$troca = true;
else if (($linhai[2] == $linhaj[2]) && ($linhai[3] == $linhaj[3]) && ($linhai[4] > $linhaj[4]))
$troca = true;
else if (($linhai[2] == $linhaj[2]) && ($linhai[3] == $linhaj[3]) && ($linhai[4] == $linhaj[4]) && ($linhai[1] > $linhaj[1]))
$troca = true;
if ($troca){
$suporte = $linhas[$i];
$linhas[$i] = $linhas[$j];
$linhas[$j] = $suporte;
}
}
}
?>
PD9waHAKICAgICRsaW5oYXMgPSBhcnJheSgKICAgICAgICAiVDM0OTcwMTJAQ0hPU1RCUkhERFNCQEVJQ01fQk9SQUBCUEhTQEJhbXoiLAogICAgICAgICJUMzQ5NzAxMkBCSE9TVEJSSEREU0JARUlDTV9CT1JBQEJQSFNAQmFteiIsCiAgICAgICAgIlQzNDk3MDEyQEFIT1NUQlJIRERTQkBFSUNNX0JPUkFAQlBIU0BCYW16IiwKICAgICAgICAiVDM0OTcwMTJAQUhPU1RCUkhERFNCQEVJQ01fQk9SQkBCUEhTQEFhbWEiLAogICAgICAgICJUMzQ5NzAxMkBBSE9TVEJSSEREU0JARUlDTV9CT1JDQEFQSFNAY2FtYSIsCiAgICAgICAgIlQyNDk3MTIzQERIT1NUQlJIRERTQkBDSUNNX0JPUkRAQVBIU0BjYW1iIiwKICAgICAgICAiVDI0OTcxMjNARUhPU1RCUkhERFNCQEJJQ01fQk9SRUBBUEhTQGNhbWMiLAogICAgICAgICJUNTU1NzAxMkBGSE9TVEJSSEREU0JAQUlDTV9CT1JGQEFQSFNAY2FtZCIKICAgICk7CgogICAgJGkgPSAxOwogICAgZm9yICgkaSA9IDA7ICRpIDwgKGNvdW50KCRsaW5oYXMpIC0gMSk7ICRpKyspewogICAgICAgICRsaW5oYWkgPSBleHBsb2RlKCJAIiwgJGxpbmhhc1skaV0pOwogICAgICAgIGZvciAoJGogPSAkaSArIDE7ICRqIDwgY291bnQoJGxpbmhhcyk7ICRqKyspewogICAgICAgICAgICAkbGluaGFqID0gZXhwbG9kZSgiQCIsICRsaW5oYXNbJGpdKTsKCiAgICAgICAgICAgICR0cm9jYSA9IGZhbHNlOwogICAgICAgICAgICBpZiAoJGxpbmhhaVsyXSA+ICRsaW5oYWpbMl0pCiAgICAgICAgICAgICAgICAkdHJvY2EgPSB0cnVlOwogICAgICAgICAgICBlbHNlIGlmICgoJGxpbmhhaVsyXSA9PSAkbGluaGFqWzJdKSAmJiAoJGxpbmhhaVszXSA+ICRsaW5oYWpbM10pKQogICAgICAgICAgICAgICAgJHRyb2NhID0gdHJ1ZTsKICAgICAgICAgICAgZWxzZSBpZiAoKCRsaW5oYWlbMl0gPT0gJGxpbmhhalsyXSkgJiYgKCRsaW5oYWlbM10gPT0gJGxpbmhhalszXSkgJiYgKCRsaW5oYWlbNF0gPiAkbGluaGFqWzRdKSkKICAgICAgICAgICAgICAgICR0cm9jYSA9IHRydWU7CiAgICAgICAgICAgIGVsc2UgaWYgKCgkbGluaGFpWzJdID09ICRsaW5oYWpbMl0pICYmICgkbGluaGFpWzNdID09ICRsaW5oYWpbM10pICYmICgkbGluaGFpWzRdID09ICRsaW5oYWpbNF0pICYmICgkbGluaGFpWzFdID4gJGxpbmhhalsxXSkpCiAgICAgICAgICAgICAgICAkdHJvY2EgPSB0cnVlOwoKICAgICAgICAgICAgaWYgKCR0cm9jYSl7CiAgICAgICAgICAgICAgICAkc3Vwb3J0ZSA9ICRsaW5oYXNbJGldOwogICAgICAgICAgICAgICAgJGxpbmhhc1skaV0gPSAkbGluaGFzWyRqXTsKICAgICAgICAgICAgICAgICRsaW5oYXNbJGpdID0gJHN1cG9ydGU7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICB2YXJfZHVtcCgkbGluaGFzKTsKPz4=