Category order -wayward line in scatter plot

I would like to create y-two axes plot with bar chart and line chart for each category. But I wante to change category sequence on x-axis, I use categoryorder="array". It’ works for bar chart but not for line chart.

Can you help me?

      mutate(cut_numeric = as.integer(cut)) %>% 
      group_by(cut_numeric) %>%
      summarise(liczba = n(),
                mean_price = mean(price),
                mean_depth = mean(depth)) %>% 
      plot_ly() %>%  
      add_trace(x=~cut_numeric,
                y=~mean_price,
                type="scatter",
                mode = "lines",
                yaxis = "y1") %>% 
      add_trace(x=~cut_numeric,
               y=~mean_depth,
               type="scatter",
               mode = "lines",
               yaxis = "y1") %>% 
      add_trace(x=~cut_numeric,
                y=~liczba,
                type = "bar",
                yaxis = "y2",
                name = "count",
                alpha=0.5) %>%
      layout(
        title = "Double Y Axis", 
        yaxis = list(
          tickfont = list(color = "red")
        ),
        yaxis2 = list(
          tickfont = list(color = "red"),
          overlaying = "y",
          side = "right",
          title = "second y axis"
        ),
        xaxis = list(title="x",
                     type="category",
                     categoryorder= "array",
                     categoryarray = c(2,3,4,1,5))
      )