protected function orderAsset(Asset $asset, array &$assets)
    {
        $order = $asset->getOrder() and $order--;

        // If an asset already exists at the given order key then we'll add one to the order
        // so the asset essentially appears after the existing asset. This makes sense since
        // the array of assets has been reversed, so if the last asset was told to be first
        // then when we finally get to the first added asset it's added second.
        if (array_key_exists($order, $assets))
        {
            array_splice($assets, $order, 0, array(null));
        }

        $assets[$order] = $asset;

        ksort($assets);
    }