I have a mongodb document like this:
{
"_id" : 1,
"prdvalue" : 3600,
"[4,0:30,0]" : [
{
"h" : 21.0,
"l" : 30.0
}
],
"[10,0:24,55]" : [
{
"h" : 10.0,
"l" : 24.55
},
{
"h" : 10.0,
"l" : 24.55
},
{
"h" : 10.0,
"l" : 24.55
}
],
"[16,0:18,0]" : [
{
"h" : 16.0,
"l" : 18.0
},
{
"h" : 16.0,
"l" : 18.0
}
]}
Now, I want to sort the arrays inside it according to their length in descending order such that when I query this document I must get the result as shown below:
{
"_id" : 1,
"prdvalue" : 3600,
"[10,0:24,55]" : [
{
"h" : 10.0,
"l" : 24.55
},
{
"h" : 10.0,
"l" : 24.55
},
{
"h" : 10.0,
"l" : 24.55
}
],
"[16,0:18,0]" : [
{
"h" : 16.0,
"l" : 18.0
},
{
"h" : 16.0,
"l" : 18.0
}
],
"[4,0:30,0]" : [
{
"h" : 21.0,
"l" : 30.0
}
]}
Here in my question unlike previous questions, array names are different so I am not understanding how to fire the query.