Associative Arrays in PHP Help

Hello, I’ve created an associative array that contains of names and states of private schools in the USA…

<?php 
include ("Q04print.php");
 $myarray = array("Andrews" =>"MI","La Sierra" => "CA", "Oakwood" => "AL", "Pacific Union" => "CA", "SOUTHERN" => "TN", "Southwestern" => "TX", "Union" => "NE", "Walla Walla" => "WA", "Washington" => "MD");
  ksort($myarray);
  asort($myarray);
  foreach ($myarray as $x => $y) {
      print "<br />" . $x . " " . $y . "<br />";
  }

?>

Now, I need to create a separate php file, a function that prints the array showing institutions and states

It will print the function to print the table, in state order (Institution and state)
It will print the function to print the table, in institution order (Institution and state)

I’m sort of need some help doing that so your assistance would be greatly appreciated. Thanks!