code: def _sorted_resource_labels(labels):
      
      head = [label for label in TOP_RESOURCE_LABELS if label in labels]
      tail = sorted(label for label in labels if label not in TOP_RESOURCE_LABELS)
      return head + tail
docs: Sort label names, putting well-known resource labels first.