Automattic\WooCommerce\Internal\Admin\Settings

Utils::order_map_normalizepublic staticWC 1.0

Normalize an order map.

Sort the order map by the order and ensure the order values start from 0 and are consecutive.

Method of the class: Utils{}

No Hooks.

Returns

Array. The normalized order map.

Usage

$result = Utils::order_map_normalize( $order_map ): array;
$order_map(array) (required)
The order map.

Utils::order_map_normalize() code WC 10.8.1

public static function order_map_normalize( array $order_map ): array {
	// Remove entries with non-string keys (legacy/corrupt data).
	$order_map = array_filter(
		$order_map,
		fn( $key ) => is_string( $key ),
		ARRAY_FILTER_USE_KEY
	);

	asort( $order_map );

	return array_flip( array_keys( $order_map ) );
}