Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::deep_sort_with_accents
Removes accents from an array of values, sorts by the values, then returns the original array values sorted.
Method of the class: CartCheckoutUtils{}
No Hooks.
Returns
Array. Sorted array.
Usage
$result = CartCheckoutUtils::deep_sort_with_accents( $sort_array );
- $sort_array(array) (required)
- Array of values to sort.
CartCheckoutUtils::deep_sort_with_accents() CartCheckoutUtils::deep sort with accents code WC 10.7.0
protected static function deep_sort_with_accents( $sort_array ) {
if ( ! is_array( $sort_array ) || empty( $sort_array ) ) {
return $sort_array;
}
$array_without_accents = array_map(
function ( $value ) {
return is_array( $value )
? self::deep_sort_with_accents( $value )
: remove_accents( wc_strtolower( html_entity_decode( $value ) ) );
},
$sort_array
);
asort( $array_without_accents );
return array_replace( $array_without_accents, $sort_array );
}