code: def pages_in_preferred_order(pages):
      tab_order = [
          x.lower().strip()
          for x in shared.opts.ui_extra_networks_tab_reorder.split(",")
      ]
  
      def tab_name_score(name):
          name = name.lower()
          for i, possible_match in enumerate(tab_order):
              if possible_match in name:
                  return i
  
          return len(pages)
  
      tab_scores = {
          page.name: (tab_name_score(page.name), original_index)
          for original_index, page in enumerate(pages)
      }
  
      return sorted(pages, key=lambda x: tab_scores[x.name])
  
imports: import functools
  import os.path
  import urllib.parse
  from pathlib import Path
  from modules import shared, ui_extra_networks_user_metadata, errors, extra_networks
  from modules.images import read_info_from_image, save_image_with_geninfo
  import gradio
  import json
  import html
  from fastapi.exceptions import HTTPException
  from modules.generation_parameters_copypaste import image_from_url_text
  from modules.ui_components import ToolButton
label_desc: Use image node_id 11 for calling a global function with example usage: pages_in_preferred_order(pages) and returns: sorted, len, i