class_docstr: Resolves inputs to a query (e.g. metrics, group by items into concrete specs.
class_docstr_tok: ["Resolves","inputs","to","a","query","(","e.g",".","metrics",",","group","by","items","into","concrete","specs","."]
code: def _resolve_order_by(
      resolver_inputs_for_order_by_items: Sequence[
          ResolverInputForOrderByItem
      ],
      metric_specs: Sequence[MetricSpec],
      group_by_item_specs: Sequence[LinkableInstanceSpec],
      query_resolution_path: MetricFlowQueryResolutionPath,
  ) -> ResolveOrderByResult:
      mapping_items: List[InputToIssueSetMappingItem] = []
      order_by_specs: List[OrderBySpec] = []
  
      # Match the pattern from the order by input to one of the metric or group-by-item specs.
      # The pattern needs to be used because there are cases where the order-by-item is specified in a different way
      # from the group-by-item, so an equality comparison won't work.
      for (
          resolver_input_for_order_by
      ) in resolver_inputs_for_order_by_items:
          matching_specs: List[InstanceSpec] = []
          for (
              possible_input
          ) in resolver_input_for_order_by.possible_inputs:
              spec_pattern = possible_input.spec_pattern
              matching_specs.extend(spec_pattern.match(metric_specs))
              matching_specs.extend(
                  spec_pattern.match(group_by_item_specs)
              )
  
          if len(matching_specs) != 1:
              mapping_items.append(
                  InputToIssueSetMappingItem(
                      resolver_input=resolver_input_for_order_by,
                      issue_set=MetricFlowQueryResolutionIssueSet.from_issue(
                          InvalidOrderByItemIssue.from_parameters(
                              order_by_item_input=resolver_input_for_order_by,
                              query_resolution_path=query_resolution_path,
                          )
                      ),
                  )
              )
          else:
              order_by_specs.append(
                  OrderBySpec(
                      instance_spec=matching_specs[0],
                      descending=resolver_input_for_order_by.descending,
                  )
              )
  
      return ResolveOrderByResult(
          input_to_issue_set_mapping=InputToIssueSetMapping(
              items=tuple(mapping_items)
          ),
          order_by_specs=tuple(order_by_specs),
      )
  
imports: from __future__ import annotations
  import logging
  from dataclasses import dataclass
  from typing import List, Optional, Sequence, Tuple
  from dbt_semantic_interfaces.references import MetricReference
  from metricflow.dag.dag_to_text import dag_as_text
  from metricflow.mf_logging.pretty_print import mf_pformat
  from metricflow.mf_logging.runtime import log_runtime
  from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
  from metricflow.naming.metric_scheme import MetricNamingScheme
  from metricflow.query.group_by_item.filter_spec_resolution.filter_pattern_factory import WhereFilterPatternFactory
  from metricflow.query.group_by_item.filter_spec_resolution.filter_spec_lookup import FilterSpecResolutionLookUp
  from metricflow.query.group_by_item.filter_spec_resolution.filter_spec_resolver import WhereFilterSpecResolver
  from metricflow.query.group_by_item.group_by_item_resolver import GroupByItemResolution, GroupByItemResolver
  from metricflow.query.group_by_item.resolution_dag.dag import GroupByItemResolutionDag
  from metricflow.query.group_by_item.resolution_dag.dag_builder import GroupByItemResolutionDagBuilder
  from metricflow.query.group_by_item.resolution_dag.resolution_nodes.query_resolution_node import QueryGroupByItemResolutionNode
  from metricflow.query.group_by_item.resolution_path import MetricFlowQueryResolutionPath
  from metricflow.query.issues.issues_base import MetricFlowQueryResolutionIssueSet
  from metricflow.query.issues.parsing.invalid_limit import InvalidLimitIssue
  from metricflow.query.issues.parsing.invalid_metric import InvalidMetricIssue
  from metricflow.query.issues.parsing.invalid_min_max_only import InvalidMinMaxOnlyIssue
  from metricflow.query.issues.parsing.invalid_order import InvalidOrderByItemIssue
  from metricflow.query.query_resolution import InputToIssueSetMapping, InputToIssueSetMappingItem, MetricFlowQueryResolution
  from metricflow.query.resolver_inputs.query_resolver_inputs import ResolverInputForGroupByItem, ResolverInputForLimit, ResolverInputForMetric, ResolverInputForMinMaxOnly, ResolverInputForOrderByItem, ResolverInputForQuery, ResolverInputForQueryLevelWhereFilterIntersection, ResolverInputForWhereFilterIntersection
  from metricflow.query.suggestion_generator import QueryItemSuggestionGenerator
  from metricflow.query.validation_rules.query_validator import PostResolutionQueryValidator
  from metricflow.specs.patterns.match_list_pattern import MatchListSpecPattern
  from metricflow.specs.specs import InstanceSpec, LinkableInstanceSpec, LinkableSpecSet, MetricFlowQuerySpec, MetricSpec, OrderBySpec
label_desc: Use image node_id 5 for calling the MetricFlowQueryResolver obj's underlying member method code with example usage: obj._resolve_order_by(resolver_inputs_for_order_by_items, metric_specs, group_by_item_specs, query_resolution_path) and returns: ResolveOrderByResult