|
|
|
| Title : |
A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array. |
| Categories : |
Algorithms, Arrays, PHP, Complete Programs |
 Petter Nilsen |
| Date : |
Jan 17th 1999 |
| Grade : |
3 of 5 (graded 10 times) |
| Viewed : |
18871 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Petter Nilsen |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?php
function bubblesort($a1,$a2)
{
for($i = sizeof($a1); $i >= 1; $i--)
{
for($j = 1; $j <= $i; $j++)
{
if($a1[$j-1] > $a1[$j])
{
$t = $a1[$j-1];
$t2 = $a2[$j-1];
$a1[$j-1] = $a1[$j];
$a2[$j-1] = $a2[$j];
$a1[$j] = $t;
$a2[$j] = $t2;
}
}
}
}
?>
|
|
| quick sort for associative arrays Categories : Algorithms, Arrays, PHP | | | A recursive function to traverse a multi-dimensional array where the
dimensions are not known Categories : Arrays, PHP, Algorithms | | | navbar.php3 - Dynamic hyperlinked navigation bars Categories : HTML and PHP, Arrays, PHP, Complete Programs | | | minus - subtract arrays. Send two arrays and get an array with the operation A-B, elements on A that are not included on B. Categories : PHP, Arrays, Algorithms | | | Browse a MySQL database & draw a tree view & load final items into a template page. Categories : MySQL, Complete Programs, Algorithms, PHP, Databases | | | A class to put get and post variables in hidden form
elements. Works on scalars, normal arrays, associative
arrays. Categories : Algorithms, Variables, Arrays, PHP, PHP Classes | | | Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers. Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms | | | php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage Categories : PHP, AJAX, XML, Complete Programs | | | PHPDRAW, the php wannabe Photoshop ;-) Categories : PHP, PHP Classes, GD image library, Arrays | | | simple shopping cart for php3 Categories : PHP, PHP Classes, Complete Programs, Ecommerce | | | Look for the *position* of the first occurence of string2
in string1, beginning at position start.
Categories : Complete Programs, PHP, Strings | | | How to load a query result into a PHP Array Categories : PHP, Databases, Arrays, MySQL | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Handle multiple file upload Categories : Complete Programs, Filesystem, PHP, HTML and PHP | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | |
| |
| | | | | igor petrov wrote :66
IMHO there is one mistake in 4-th line of the example
361.
for($i = sizeof($a1); $i >= 1; $i--)
should be like
for($i = sizeof($a1) - 1; $i >= 1; $i--)
| |
|
|