<html>
<body bgcolor=lightyellow>

<h1 Align=center>Sorting a 2 Dimenstional Array</h1>
<h2 Align=center>Sort and Print Functions Required</h2>

<?php
//  require "requirePrint.php";				
//  require "requireSort.php";
    require "/home/sultans/web/php/demo/2function/requirePrint.php";        //use explicit file path 
    require "/home/sultans/web/php/demo/2function/requireSort.php";         //to make it work in the PHP*Tester

    $student1 = array('id'=>1, 'lname'=>'Burns',    'fname'=>'Barbara', 'ssn'=>'000-01-0001', 'sex'=>'F');
    $student2 = array('id'=>2, 'lname'=>'Cambria',  'fname'=>'Vincent', 'ssn'=>'000-01-0002', 'sex'=>'M');
    $student3 = array('id'=>4, 'lname'=>'Davidson', 'fname'=>'Duncan',  'ssn'=>'000-01-0004', 'sex'=>'M');
    $student4 = array('id'=>4, 'lname'=>'Runyan',   'fname'=>'David',   'ssn'=>'000-01-0004', 'sex'=>'M');
    $student5 = array('id'=>5, 'lname'=>'Thomas',   'fname'=>'Eugene',  'ssn'=>'000-01-0005', 'sex'=>'M');
    $student6 = array('id'=>6, 'lname'=>'Owens',    'fname'=>'Cynthia', 'ssn'=>'000-01-0006', 'sex'=>'F');
    $students = array($student1, $student2, $student3, $student4, $student5, $student6);

    print "<b>The Original Students Array: </b><br><pre>";
    print_table( $students );
    print "</pre><hr/>";

    usort($students, 'by_lname_fname');    
    
    print "<b>After Sorting by Lastname then Firstname: </b><br><pre>";
    print_table( $students );
    print "</pre><hr/>";

    usort($students, 'by_lname_fname_desc');    
    
    print "<b>After Sorting by Lastname then Firstname (Descending): </b><br><pre>";
    print_table( $students );
    print "</pre><hr/>";

    usort($students, 'by_lname_ignore_case');    
    
    print "<b>After Sorting by Lastname (Ignoring Case): </b><br><pre>";
    print_table( $students );
    print "</pre><hr/>";

    usort($students, 'by_id_desc');    
    
    print "<b>After Sorting by id (Descending): </b><br><pre>";
    print_table( $students );
    print "</pre><hr/>";
    
?>

<?php include "../include.php"; ?>              <!-- hyperlink to see the code -->
</body>
</html>