protected function sortByWeight(array $locales)
    {
        // new index
        $index = [];

        // for those who are interested in (int) or intval() whats faster:
        // http://www.entwicklerblog.net/php/php-variable-in-integer-verwandeln-intfoo-oder-intvalfoo/
        foreach ($locales as $localeSet) {
            $index[$localeSet['locale']] = (int) $localeSet['weight'];
        }

        // make values the keys
        $index = array_flip($index);

        // sort by key
        krsort($index);

        // rebuild
        $locales = [];

        foreach ($index as $weight => $locale) {
            $locales[] = [
                'locale' => $locale,
                'weight' => ($weight / 10), // restore the correct weight here -> after sorting
            ];
        }

        return $locales;
    }