Automattic\WooCommerce\Blocks\Utils

CartCheckoutUtils::deep_sort_with_accents()protected staticWC 1.0

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.

Return

Array. Sorted array.

Usage

$result = CartCheckoutUtils::deep_sort_with_accents( $array );
$array(array) (required)
Array of values to sort.

CartCheckoutUtils::deep_sort_with_accents() code WC 9.4.2

protected static function deep_sort_with_accents( $array ) {
	if ( ! is_array( $array ) || empty( $array ) ) {
		return $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 ) ) );
		},
		$array
	);

	asort( $array_without_accents );
	return array_replace( $array_without_accents, $array );
}