Solution :
uksort($locationArray$testArray, function ($key1, $key2) {
// Extract letters from keys
$letter1 = substr($key1, -1);
$letter2 = substr($key2, -1);
// Compare letters
$letterComparison = strcmp($letter1, $letter2);
// If letters are the same, sort by numeric part of keys
if ($letterComparison === 0) {
$numericPart1 = (int) substr($key1, 3, -1); // Extract numeric part of key1
$numericPart2 = (int) substr($key2, 3, -1); // Extract numeric part of key2
return $numericPart1 - $numericPart2; // Compare numeric parts
}
return $letterComparison;
});