Login   Register  
PHP Classes
elePHPant
Icontem

File: ex_sorting.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Danny Tucker  >  EZ Framework  >  ex_sorting.php  >  Download  
File: ex_sorting.php
Role: Example script
Content type: text/plain
Description: Example
Class: EZ Framework
Framework providing several types of functionality
Author: By
Last change:
Date: 8 years ago
Size: 1,424 bytes
 

Contents

Class file image Download
<?php
# Version 1.0
require_once('../include/config.inc.php');

$a = array('a','a','a','b','b','u','k','b','a','d');
$b = array('a','a','a','g','b','a','gh','d','a','s');
$c = array('moike','baob','aaspen','bmobby','anne','erin','oden','boy','arial','yolanda');

for(
$i=0;$i<count($a);$i++)
{
    
$ar[$i]['one'] = $a[$i];
    
$ar[$i]['two'] = $b[$i];
    
$ar[$i]['three'] = $c[$i];
}
// Single Dem. Array
$ar = array('a','a','c','c','e','a','aa','a1','2a','2a');

// Create sorting object, send in (type of sort, and sort flags) both optional
// ($the array,which keys to sort by - can send in multiple keys to sort by,
// the order of the sort will be from left to right
$sorting = new sorting();

foreach(
$sorting->sort_list($ar,'one','two') as $a)
    echo 
"$a[one]-$a[two]<br>";
echo 
'<br>';

// Reverse the current sort method
$sorting->reverse();

//foreach($sorting->sort_list($ar,'one','two') as $a)echo "$a[one]-$a[two]<br>";echo '<br>';
$t $sorting->sort_list($ar,'two','one');

foreach(
$t as $a)
    echo 
"$a[one]-$a[two]<br>";
echo 
'<br>';

// Reverse the current sort method
$sorting->reverse();

foreach(
$sorting->sort_list($ar,'one','two','three') as $a)
    echo 
"$a[one]-$a[two]-$a[three]<br>";
echo 
'<br>';

// Set the current sort method
$sorting->sort_by 'arsort';

foreach(
$sorting->sort_list($ar,'two','one') as $a)
    echo 
"$a[one]-$a[two]<br>";
echo 
'<br>';
            
?>