Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = readline();
- $company = [];
- while (true) {
- if ($input == "End") {
- break;
- }
- $args = explode(" -> ", $input);
- $companyName = $args[0];
- $employeeID = $args[1];
- if (!key_exists($employeeID, $company)) {
- $company[$companyName][] = $employeeID;
- }
- $input = readline();
- }
- uksort($company, function ($id1, $id2) use ($company) {
- $count1 = count($company[$id2]);
- $count2 = count($company[$id1]);
- if ($count1 === $count2) {
- return $count1 <=> $count2;
- }
- return $count2 <=> $count1;
- });
- foreach ($company as $key => $value) {
- asort($value);
- $count = count($value);
- echo $key . PHP_EOL;
- foreach ($value as $id) {
- echo "-- " . $id . PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement