code: public static List<SourceFile> prepareExterns(CompilerOptions.Environment env,
          Map<String, SourceFile> externs) {
      List<SourceFile> out = new ArrayList<>();
  
      for (String key : BUILTIN_LANG_EXTERNS) {
        Preconditions.checkState(externs.containsKey(key), "Externs must contain builtin: %s", key);
        out.add(externs.remove(key));
      }
  
      if (env == CompilerOptions.Environment.BROWSER) {
        for (String key : BROWSER_EXTERN_DEP_ORDER) {
          Preconditions.checkState(externs.containsKey(key),
              "Externs must contain builtin for env %s: %s", env, key);
          out.add(externs.remove(key));
        }
  
        out.addAll(externs.values());
      }
  
      return out;
    }
docs: Filters and orders the passed externs for the specified environment.
  
  @param env The environment being used.
  @param externs Flat tilename to source externs map. Must be mutable and will be modified.
  @return Ordered list of externs.