Sorting on opensearch dashboard

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Version used is v 1.3.8

Describe the issue:
Is there any way to do custom sorting?
I want to sort this graph in which 400 code count is shown first.
on x-axis, interaction which has highest number of 400 count should be shown first on the graph. So it would look like this, first on x-axis there will be F3 stack then F4 stack and then F2 stack and then F5 and then F1

Relevant Logs or Screenshots:

@Ayushi I think you would need a separate graph for ‘400’ value as the current graph sorts by overall Interactions.

Hi @pablo, thank you for replying.
Current graph sorts interactions with total count highest as first. But i want interactions to be sort in a way where bar stack with highest 400 count to be first on the x-axis.
Isn’t it possible in a single graph using a custom metric or by advance json input . Screenshot attached.

I tried creating a query, but it didn’t work.
{
“size”:0,
“aggs”: {
“status_counts” :{
“terms”: {
“field”: “tags.journeyInteraction”,
“order” : {
“max_400_count”: “desc”
}
},
“aggs”:{
“max_400_count”:{
“max”: {
“script”: {
“source”: “doc[‘http#status_code’].value == 400 ? 1:0”
}
}
}
}
}
}
}