Differences Between: [Versions 310 and 403]
Defines string apis
Copyright: | 2011 Sam Hemelryk |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 349 lines (15 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
core_collator:: (10 methods):
__construct()
ensure_collator_available()
restore_array()
naturalise()
callback_naturalise()
asort()
asort_objects_by_property()
asort_objects_by_method()
asort_array_of_arrays_by_key()
ksort()
Class: core_collator - X-Ref
A collator class with static methods that can be used for sorting.__construct() X-Ref |
Prevent class instances, all methods are static. |
ensure_collator_available() X-Ref |
Ensures that a collator is available and created return: bool Returns true if collation is available and ready |
restore_array(array &$arr, array &$original) X-Ref |
Restore array contents keeping new keys. param: array $arr param: array $original return: void modifies $arr |
naturalise($string) X-Ref |
Normalise numbers in strings for natural sorting comparisons. param: string $string return: string string with normalised numbers |
callback_naturalise($matches) X-Ref |
param: array $matches return: string |
asort(array &$arr, $sortflag = core_collator::SORT_STRING) X-Ref |
Locale aware sorting, the key associations are kept, values are sorted alphabetically. param: array $arr array to be sorted (reference) param: int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR return: bool True on success |
asort_objects_by_property(array &$objects, $property, $sortflag = core_collator::SORT_STRING) X-Ref |
Locale aware sort of objects by a property in common to all objects param: array $objects An array of objects to sort (handled by reference) param: string $property The property to use for comparison param: int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR return: bool True on success |
asort_objects_by_method(array &$objects, $method, $sortflag = core_collator::SORT_STRING) X-Ref |
Locale aware sort of objects by a method in common to all objects param: array $objects An array of objects to sort (handled by reference) param: string $method The method to call to generate a value for comparison param: int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR return: bool True on success |
asort_array_of_arrays_by_key(array &$array, $key, $sortflag = core_collator::SORT_STRING) X-Ref |
Locale aware sort of array of arrays. Given an array like: $array = array( array('name' => 'bravo'), array('name' => 'charlie'), array('name' => 'alpha') ); If you call: core_collator::asort_array_of_arrays_by_key($array, 'name') You will be returned $array sorted by the name key of the subarrays. e.g. $array = array( array('name' => 'alpha'), array('name' => 'bravo'), array('name' => 'charlie') ); param: array $array An array of objects to sort (handled by reference) param: string $key The key to use for comparison param: int $sortflag One of return: bool True on success |
ksort(array &$arr, $sortflag = core_collator::SORT_STRING) X-Ref |
Locale aware sorting, the key associations are kept, keys are sorted alphabetically. param: array $arr array to be sorted (reference) param: int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR return: bool True on success |