protected function sortByWeight(array $definitions) {
    // Sort definitions by weight before returning.
    uasort($definitions, function ($first, $second) {
      if ($first['weight'] === $second['weight']) {
        return 0;
      }
      return ($first['weight'] < $second['weight']) ? -1 : 1;
    });

    return $definitions;
  }