Do a Schwartzian Transform for stable sort.

@see http://en.wikipedia.org/wiki/Schwartzian_transform

@param AssetInterface[] $assets

@return AssetInterface[]
350765
protected function sort(array $assets)
    {
        array_walk(
            $assets,
            function (&$v, $k) {
                /** @var AssetInterface $v */
                $v = [$v->getPriority(), $k, $v];
            }
        );

        sort($assets);

        array_walk(
            $assets,
            function (&$v) {
                $v = $v[2];
            }
        );

        return $assets;
    }
80694
public function render($type, $assets)
    {
        if (! in_array($type, $this->types)) {
            throw new InvalidArgumentException("Invalid assets type [${type}]");
        }

        // The assets type is valid.
        else if (! empty($items = $this->parseAssets($assets))) {
            return implode("\n", $this->renderItems($items, $type, false));
        }
    }
354333
private function fillTransforms($transforms): array
    {
        $r = [];

        $attributeName = self::$transformConfig->fillAttribute;
        $interval = self::$transformConfig->fillInterval;

        $r[] = $transforms[0];

        for ($i = 1, $l = \count($transforms); $i < $l; $i++) {
            $prevTransform = $transforms[$i - 1];
            $currentTransform = $transforms[$i];

            if (isset($prevTransform[$attributeName], $currentTransform[$attributeName])) {
                if ($prevTransform[$attributeName] < $currentTransform[$attributeName]) {
                    for ($num = $prevTransform[$attributeName] + $interval, $maxNum = $currentTransform[$attributeName]; $num < $maxNum; $num += $interval) {
                        $transformCopy = $prevTransform;
                        $transformCopy[$attributeName] = $num;
                        $r[] = $transformCopy;
                    }
                } else {
                    for ($num = $prevTransform[$attributeName] - $interval, $minNum = $currentTransform[$attributeName]; $num > $minNum; $num -= $interval) {
                        $transformCopy = $prevTransform;
                        $transformCopy[$attributeName] = $num;
                        $r[] = $transformCopy;
                    }
                }
            }

            $r[] = $currentTransform;
        }

        return $r;
    }
69234
public static function process($assets)
    {
        if ($directory = self::getOutputDirectory()) {
            $relativeDirectory = self::getRelativeOutputDirectory();
            $filename = '';
            $sourceFiles = array();
            for ($i = 0; $i < count($assets); ++$i) {
                $asset = $assets[$i];
                $filename .= $asset->getAssetHashKey();
                $sourceFiles[] = $asset->getAssetURL();
            }
            $filename = sha1($filename);
            $cacheFile = $directory.'/'.$filename.'.js';
            if (!file_exists($cacheFile)) {
                $js = '';
                foreach ($assets as $asset) {
                    $contents = $asset->getAssetContents();
                    if (isset($contents)) {
                        if ($asset->assetSupportsMinification()) {
                            $contents = \JShrink\Minifier::minify($contents);
                        }
                        $js .= $contents.";\n\n";
                    }
                }
                @file_put_contents($cacheFile, $js);
            }

            $asset = new self();
            $asset->setAssetURL($relativeDirectory.'/'.$filename.'.js');
            $asset->setAssetPath($directory.'/'.$filename.'.js');
            $asset->setCombinedAssetSourceFiles($sourceFiles);

            return array($asset);
        }

        return $assets;
    }
224563
public function filterDump(AssetInterface $asset)
    {
        $pb = $this->createProcessBuilder($this->nodeBin
            ? array($this->nodeBin, $this->cleanCssBin)
            : array($this->cleanCssBin));

        if ($this->keepLineBreaks) {
            $pb->add('--keep-line-breaks');
        }

        if ($this->compatibility) {
            $pb->add('--compatibility ' .$this->compatibility);
        }

        if ($this->debug) {
            $pb->add('--debug');
        }

        if ($this->rootPath) {
            $pb->add('--root ' .$this->rootPath);
        }

        if ($this->skipImport) {
            $pb->add('--skip-import');
        }

        if ($this->timeout) {
            $pb->add('--timeout ' .$this->timeout);
        }

        if ($this->roundingPrecision) {
            $pb->add('--rounding-precision ' .$this->roundingPrecision);
        }

        if ($this->removeSpecialComments) {
            $pb->add('--s0');
        }

        if ($this->onlyKeepFirstSpecialComment) {
            $pb->add('--s1');
        }

        if ($this->semanticMerging) {
            $pb->add('--semantic-merging');
        }

        if ($this->skipAdvanced) {
            $pb->add('--skip-advanced');
        }

        if ($this->skipAggresiveMerging) {
            $pb->add('--skip-aggressive-merging');
        }

        if ($this->skipImportFrom) {
            $pb->add('--skip-import-from ' .$this->skipImportFrom);
        }

        if ($this->mediaMerging) {
            $pb->add('--skip-media-merging');
        }

        if ($this->skipRebase) {
            $pb->add('--skip-rebase');
        }

        if ($this->skipRestructuring) {
            $pb->add('--skip-restructuring');
        }

        if ($this->skipShorthandCompacting) {
            $pb->add('--skip-shorthand-compacting');
        }

        if ($this->sourceMap) {
            $pb->add('--source-map');
        }

        if ($this->sourceMapInlineSources) {
            $pb->add('--source-map-inline-sources');
        }
        // input and output files
        $input = tempnam(sys_get_temp_dir(), 'input');

        file_put_contents($input, $asset->getContent());
        $pb->add($input);

        $proc = $pb->getProcess();
        $code = $proc->run();
        unlink($input);

        if (127 === $code) {
            throw new \RuntimeException('Path to node executable could not be resolved.');
        }

        if (0 !== $code) {
            throw FilterException::fromProcess($proc)->setInput($asset->getContent());
        }

        $asset->setContent($proc->getOutput());
    }
1097188
private function addAsset(AssetInterface $asset)
    {
        if ($asset instanceof FileAssetInterface) {
            $this->normalizeAsset($asset);
        }
        $this->assets[] = $asset;
    }
1001237
public function before($asset = null)
    {
        $movedAssets = $this->lastTouchedAssetsOrFail();

        if ($asset === null) {
            $this->moveAssetsToPrependings($this->lastTouchedGroup, $movedAssets);

            return $this;
        }

        $positionId = $this->positionId($asset);

        if (!isset($this->befores[$positionId])) {
            $this->befores[$positionId] = [];
        }

        $this->moveAssetsToPassedArray($this->befores[$positionId], $movedAssets);

        return $this;
    }
141367
public function get( $type = null ) 
	{
		if ( is_null( $type ) )
		{
			return $this->assets;
		}
		
		if ( !isset( $this->assets[$type] ) )
		{
			return array();
		}
		
		return $this->assets[$type];
	}
1130014
private function applyWorkers(AssetCollectionInterface $asset)
    {
        foreach ($asset as $leaf) {
            foreach ($this->workers as $worker) {
                $retval = $worker->process($leaf, $this);

                if ($retval instanceof AssetInterface && $leaf !== $retval) {
                    $asset->replaceLeaf($leaf, $retval);
                }
            }
        }

        foreach ($this->workers as $worker) {
            $retval = $worker->process($asset, $this);

            if ($retval instanceof AssetInterface) {
                $asset = $retval;
            }
        }

        return $asset instanceof AssetCollectionInterface ? $asset : $this->createAssetCollection(array($asset));
    }
733158
public function transformImage ($asset = null, $transforms = null, $defaultOptions = [])
    {
        return Imgix::$plugin->imgixService->transformImage($asset, $transforms, $defaultOptions);
    }
840468
public function assets($type = 'css')
    {
        $output = [];
        $assets = $this->Assets->getAssets($type);
        foreach ($assets as $asset) {
            $output[] = $asset['output'];
        }

        return implode($this->eol, $output);
    }
866541
public function set_assets( $assets ) {

		foreach ( $assets as $type => $asset ) {
			$this->enqueue( $asset, $type );
		}
	}
85535
public function prepend($asset)
	{
		// More than one asset
		if(is_array($asset))
		{
			foreach(array_reverse($asset) as $a)
				$this->prepend($a);
		}

		// Collection
		elseif(isset($this->collections[$asset]))
			$this->prepend($this->collections[$asset]);

		// JavaScript asset
		elseif(preg_match($this->js_regex, $asset))
			$this->prependJs($asset);

		// CSS asset
		elseif(preg_match($this->css_regex, $asset))
			$this->prependCss($asset);

		return $this;
	}
1274089
protected function getDeepHashFromAssets($assets)
    {
        $key = '';

        $assetFiles = array_map(function ($file) {
            return file_exists($file) ? $file : File::symbolizePath($file, null) ?: $this->localPath . $file;
        }, $assets);

        foreach ($assetFiles as $file) {
            $filters = $this->getFilters(File::extension($file));

            foreach ($filters as $filter) {
                if (method_exists($filter, 'hashAsset')) {
                    $key .= $filter->hashAsset($file, $this->localPath);
                }
            }
        }

        return $key;
    }
1294255
protected function resolveDependenciesForAsset(&$assets, $asset, $replaces)
    {
        foreach ($assets as $name => $value) {
            $changed = false;

            foreach ($value['dependencies'] as $key => $dependency) {
                if (in_array($dependency, $replaces)) {
                    $changed = true;
                    unset($value['dependencies'][$key]);
                }
            }

            if ($changed) {
                $value['dependencies'][]       = $asset;
                $assets[$name]['dependencies'] = $value['dependencies'];
            }
        }

        $assets[$asset]['replaces'] = [];
    }
377251
protected function transform($transforms)
    {
        if (!$transforms) {
            return null;
        }
        if (isset($transforms[0])) {
            $images = [];

            foreach ($transforms as $transform) {
                $transform = array_merge($this->defaultOptions, $transform);
                $transform = $this->calculateTargetSizeFromRatio($transform);
                $url       = $this->buildTransform($this->imagePath, $transform);
                $images[]  = array_merge($transform, ['url' => $url]);
            }

            $this->transformed = $images;
        }
        else {
            $transforms        = array_merge($this->defaultOptions, $transforms);
            $transforms        = $this->calculateTargetSizeFromRatio($transforms);
            $url               = $this->buildTransform($this->imagePath, $transforms);
            $image             = array_merge($transforms, ['url' => $url]);
            $this->transformed = $image;
        }
    }
1299836
protected function fixAssets(array $assets)
    {
        $ignore = array('jquery-last.min.js',
                        'jquery-ui.min.js',
                        'jquery.easing-1.3.js',
                        'jquery.metadata.js',
                        'jquery.ui.position.js',);
        foreach ($assets as $key => $asset) {
            if (in_array(basename($asset), $ignore)) {
                unset($assets[$key]);
            }
        }

        return $assets;
    }