Function __global->sort_maps_by

Definitions

sources/global3.php

  • Sort a list of maps by a particular key ID in the maps. Does not (and should not) preserve list indices, but does preserve associative key indices.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
&$rows array Yes No required parameter N/A N/A List of maps to sort
$sort_keys mixed No No required parameter N/A N/A Either an integer sort key (to sort by integer key ID of contained arrays) or a Comma-separated list of sort keys (to sort by string key ID of contained arrays; prefix '!' a key to reverse the sort order for it)
$preserve_order_if_possible boolean No No False N/A N/A Don't shuffle order unnecessarily (i.e. do a merge sort)
$natural boolean No No False N/A N/A Whether to do a natural sort

Preview

Code (PHP)

/**
 * Sort a list of maps by a particular key ID in the maps. Does not (and should not) preserve list indices, but does preserve associative key indices.
 *
 * @param  array $rows List of maps to sort
 * @param  mixed $sort_keys Either an integer sort key (to sort by integer key ID of contained arrays) or a Comma-separated list of sort keys (to sort by string key ID of contained arrays; prefix '!' a key to reverse the sort order for it)
 * @param  boolean $preserve_order_if_possible Don't shuffle order unnecessarily (i.e. do a merge sort)
 * @param  boolean $natural Whether to do a natural sort
 */

function sort_maps_by(array &$rows, $sort_keys, bool $preserve_order_if_possible = false, bool $natural = false)