What are some best practices for organizing and structuring code when implementing sorting functionality in a PHP application?

When implementing sorting functionality in a PHP application, it is important to organize and structure your code in a way that is clear, efficient, and maintainable. One best practice is to create a separate class or function specifically for sorting logic, keeping it separate from other parts of your code. You can also use built-in PHP functions like `usort()` or `uasort()` for sorting arrays with custom comparison logic.

class SortingHelper {
    public static function sortByKey(array $array, $key) {
        usort($array, function($a, $b) use ($key) {
            return $a[$key] <=> $b[$key];
        });
        return $array;
    }
}

// Example usage
$data = [
    ['name' => 'John', 'age' => 30],
    ['name' => 'Jane', 'age' => 25],
    ['name' => 'Doe', 'age' => 35]
];

$sortedData = SortingHelper::sortByKey($data, 'age');
print_r($sortedData);