O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

sort

Synopsis

bool sort(array array[, int flags])

Sorts the values in the given array in ascending order. For more control over the behavior of the sort, provide the second parameter, which is one of the following values:

SORT_REGULAR (default)

Compare the items normally.

SORT_NUMERIC

Compare the items numerically.

SORT_STRING

Compare the items as strings.

SORT_LOCALE_STRING

Compare the items as strings using the current locale sorting rules.

SORT_NATURAL

Compare the items as strings using “natural ordering.”

SORT_FLAG_CASE

Combine with SORT_STRING or SORT_NATURAL using a bitwise OR operation to sort using case-insensitive comparison.

Returns true if the operation was successful, or false otherwise. See Chapter 5 for more information on using this function.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required