c9s / xarray

The missing PHP array functions you are looking for, implemented in extension
42 stars 3 forks source link

array_sort_by_nested_value #12

Open vbouchet31 opened 9 years ago

vbouchet31 commented 9 years ago

For example:

$my_array = array(
  'key1' => array(
    'sub_key' => array(
      'sub_sub_key1' => 'value',
      ...
    ),
  ),
  'key2' => array(
    'sub_key' => array(
      'sub_sub_key1' => 'another value',
      ...
    ),
  ),
);

array_sort_by_nested_value($my_array, 'sub_key][sub_sub_key1');

This call should sort the nested array by using the value in [sub_key][sub_sub_key1] of each item. (With this example, keys order should be array_keys($my_array) = array('key2', 'key1);

c9s commented 9 years ago

sounds like a recursive sort ?

Can you implement a pure PHP version and we can transform it into C language in extension?