Platformsh\Cli\Api::sortResources PHP Method

sortResources() public static method

Sort resources.
public static sortResources ( array &$resources, string $propertyPath ) : Platformsh\Client\Model\Resource[]
$resources array
$propertyPath string
return Platformsh\Client\Model\Resource[]
    public static function sortResources(array &$resources, $propertyPath)
    {
        uasort($resources, function (ApiResource $a, ApiResource $b) use($propertyPath) {
            $valueA = static::getNestedProperty($a, $propertyPath, false);
            $valueB = static::getNestedProperty($b, $propertyPath, false);
            switch (gettype($valueA)) {
                case 'string':
                    return strcasecmp($valueA, $valueB);
                case 'integer':
                case 'double':
                case 'boolean':
                    return $valueA - $valueB;
            }
            return 0;
        });
        return $resources;
    }