### Bug description

Hello, To briefly explain the situation, I am an R user, but since all of the project participants are python users, I was conducting statistical analysis using both python and R. However, when using R chunk and python chunk at the same time, it seems that the order of subcaptions is not rendered as I intended. Should the simultaneous use of multiple quarto engines be discouraged? In other words, if I choose to use Python, should I stick with Python?

````
---
title-block-banner: true
title: "Something1"
subtitle: "Something2"
date: 2023-04-03
author: "Someone"
institute: "Something3"
format:
  html:
  #pdf:
    #documentclass: scrartcl
    #papersize: a4
    toc: true
    number-sections: true
    lot: true
    lof: true
    code-fold: true
    #df-print: paged
    fig-width: 15
    fig-height: 15
    #fontfamily: libertinus
    #colorlinks: true
execute:
  warning: false
  message: false
  echo: false
---

# Analysis With R 

## Load Packages

```{r}
#| eval: false

# install.packages('tidyverse')
# install.packages('reticulate')
# install.packages('arrow')

library(tidyverse)
library(reticulate)
library(knitr)
library(kableExtra)
#library(arrow)
#library(readr)
options(dplyr.summarise.inform = FALSE)
```


# Anlaysis with Python

## Load Packages

```{python load_packages}
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn 
import itertools
import os
from IPython.display import display, Markdown # for dynamic documentation
from tabulate import tabulate # for dynamic documentation
from pandas.api.types import CategoricalDtype # for factoring categorical variables
from sklearn.metrics import confusion_matrix #, accuracy_score, precision_score, recall_score, f1_score

pd.set_option('display.max_rows', 100)
# pd.set_option('display.max_columns', 10)
# pd.set_option('display.width', 1000)
pd.options.mode.chained_assignment = None 
```

## Data Load

```{python}
# Long form data generation
data1 = {'dataid': np.repeat(range(0,100), 6),
        'cycle': np.tile(range(6), 100),
        'rfu': np.random.randn(600),
        'scenario': np.repeat('scenario00',600),
        'template': np.repeat([chr(i) for i in range(65, 71)],100)}

# Convert to pandas DataFrame
unnested_dsp_error_data = pd.DataFrame(data1)

```

## Function List

```{python, funtions}

def plot_error_signals(dataid_list,title=None,x_limits=None,y_limits=None):
  temp2=unnested_dsp_error_data[unnested_dsp_error_data.dataid.isin(dataid_list)]
  plt.title(title)
  for i in dataid_list:
    temp=unnested_dsp_error_data[(unnested_dsp_error_data.dataid==i)]
    plt.plot(temp.cycle,temp.rfu)
    if x_limits or y_limits:
      plt.ylim(x_limits,y_limits)
    else:
      plt.ylim(temp2.rfu.min()*0.9,temp2.rfu.max()*1.1)

```

## Qualititative Analysis

```{python, DSP_grand_confusion_errors}
#| label: dsp_grand_confusion_errors
#| fig-cap: "DSP Grand Missclassifed Signals"
#| echo: fenced

error_dataid=unnested_dsp_error_data.dataid.unique().tolist()

plot_error_signals(error_dataid)
plt.show()
```

```{python, DSP_error_signals_templates}
#| label: DSP_error_signals_templates
#| fig-cap: "DSP Error Signals Grouped By Templates"
#| fig-subcap: 
#|   - "A"
#|   - "B"
#|   - "C"
#|   - "D"
#|   - "E"
#|   - "F"
#| layout-ncol: 2
#| echo: fenced

template_list=[chr(i) for i in range(65, 71)]

for template in template_list:
  temp_dataid=unnested_dsp_error_data[unnested_dsp_error_data.template==template].dataid.unique()
  plot_error_signals(temp_dataid,title=template)
  plt.show()

```




````

the rendered output is like the following:

![image](https://github.com/quarto-dev/quarto-cli/assets/61118160/bd9e5d95-cdc1-441c-975b-199ffe3545d6)


### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [x] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [x] Please document the operating system you're running. If on Linux, please provide the specific distribution.
- [x] Please provide the output of `quarto check` so we know which version of quarto and its dependencies you're running.
cderv
2023-05-12T00:48:24Z
kmink3225
bug upstream
closed
Figure subcaptions are randomly arranged in an order I didn't set in a python chunk in a qmd file.
https://github.com/quarto-dev/quarto-cli/issues/5508