What potential issue could arise from the repetitive code in the sort.php file?

The potential issue that could arise from repetitive code in the sort.php file is code duplication, which can lead to maintenance difficulties and increased chances of introducing bugs. To solve this issue, we can refactor the repetitive code into a reusable function that can be called whenever needed.

// Define a function to handle the sorting logic
function customSort($data, $sortKey) {
    usort($data, function($a, $b) use ($sortKey) {
        return $a[$sortKey] <=> $b[$sortKey];
    });
    return $data;
}

// Usage example
$data = [
    ['name' => 'Alice', 'age' => 25],
    ['name' => 'Bob', 'age' => 30],
    ['name' => 'Charlie', 'age' => 20]
];

$sortedData = customSort($data, 'age');