★ wanayoo — archive 1999 http://fr.php.net/manual/function.natsort.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Arrays
Quick Reference
English version of this pageGerman version of this page is not availableJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this page is not availableDutch version of this pageBrazilian Portuguese version of this page
Korean version of this pageCzech version of this page
Arrays
* array
* array_count_values
* array_diff
* array_flip
* array_intersect
* array_keys
* array_merge
* array_merge_recursive
* array_multisort
* array_pad
* array_pop
* array_push
* array_rand
* array_reverse
* array_shift
* array_slice
* array_splice
* array_unique
* array_unshift
* array_values
* array_walk
* arsort
* asort
* compact
* count
* current
* each
* end
* extract
* in_array
* key
* krsort
* ksort
* list
* natsort
* natcasesort
* next
* pos
* prev
* range
* reset
* rsort
* shuffle
* sizeof
* sort
* uasort
* uksort
* usort

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: natsort
View the source code for this pageSearch the site



Previous page
 list
 Updated
Mon, 08 Jan 2001
natcasesort 
Next page


natsort

(PHP 4 >= 4.0RC2)

natsort --  Sort an array using a "natural order" algorithm

Description

void natsort (array array)

This function implements a sort algorithm that orders alphanumeric strings in the way a human being would. This is described as a "natural ordering". An example of the difference between this algorithm and the regular computer string sorting algorithms (used in sort()) can be seen below:

Example 1. natsort() example


$array1 = $array2 = array ("img12.png","img10.png","img2.png","img1.png");          

sort($array1);
echo "Standard sorting\n";
print_r($array1);

natsort($array2);
echo "\nNatural order sorting\n";
print_r($array2);
      

The code above will generate the following output:


Standard sorting
Array
(
    [0] => img1.png
    [1] => img10.png
    [2] => img12.png
    [3] => img2.png
)

Natural order sorting
Array
(
    [3] => img1.png
    [2] => img2.png
    [1] => img10.png
    [0] => img12.png
)
      

For more infomation see: Martin Pool's Natural Order String Comparison page.

See also natcasesort(), strnatcmp() and strnatcasecmp().


 About Notes


Previous page
 list
 Updated
Mon, 08 Jan 2001
natcasesort 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
France
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.