# Sorting grouped bar plots dependently (each traces) in Plotly

**URL:** <https://community.plotly.com/t/sorting-grouped-bar-plots-dependently-each-traces-in-plotly/61642>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [March 4, 2022, 7:10pm UTC](https://community.plotly.com/t/sorting-grouped-bar-plots-dependently-each-traces-in-plotly/61642 "2022-03-04T19:10:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali01](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Ali01](https://community.plotly.com/u/Ali01)\
**Post date:** [March 4, 2022, 7:10pm UTC](https://community.plotly.com/t/sorting-grouped-bar-plots-dependently-each-traces-in-plotly/61642/1 "2022-03-04T19:10:49Z")

</div>

Hi, I want to sort my grouped bar plots one-by-one in descending (question on [StackOverflow](https://stackoverflow.com/questions/71062505/sorting-grouped-bar-plots-dependently-in-plotly)) but didn’t find any solution, is this possible? ([I’ve found that sorting particular traces is not possible](https://plotly.com/python/bar-charts/#:~:text=Note%20that%20sorting%20the%20bars%20by%20a%20particular%20trace%20isn%27t%20possible%20right%20now)).  
Want to sort players first by their Weight, then by Height, and so on…

 ![5xaWa](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/c/b/cbdffe56f3185f3109f29a1d1e4bbae142cac17b.png)  
**My Code**

```auto
import pandas as pd
import numpy as np
import plotly.graph_objects as go

dftst = pd.DataFrame([('Arthur', 110, 200, 10),
                   ('Benson', 50, 160, 12),
                   ('Carlos', 90, 170, 14),
                   ('Dante', 160, 180, 11),
                   ('Evan', 130, 165, 18),
                   ('Frank', 70, 190, 20)],
           columns=('Name', 'Weight', 'Height', 'Score'))

pnames = dftst['Name']
x = list(range(len(pnames)))

bar_plots = [
  go.Bar(x=x, y=dftst['Weight'], name='Weight', marker=go.bar.Marker(color='#0343df')),
  go.Bar(x=x, y=dftst['Height'], name='Height', marker=go.bar.Marker(color='#e50000')),
  go.Bar(x=x, y=dftst['Score'], name='Score', marker=go.bar.Marker(color='green')),
]

layout = go.Layout(
  title=go.layout.Title(text="Players", x=0.5),
  yaxis_title="Players Details",
  xaxis_tickmode="array",
  xaxis_tickvals=list(range(6)),
  xaxis_ticktext=tuple(dftst['Name'].values))

fig = go.Figure(data=bar_plots, layout=layout)

fig.update_layout(
    autosize=False,
    width=600,
    height=700)

fig.update_layout(barmode='group', xaxis={'categoryorder':'category ascending'})

fig.update_xaxes(
    showgrid=True,
    ticks="outside",
    tickson="boundaries",
    ticklen=20
)

fig.show()

```
