Sample document looks like this:
{
_id: 1,
"somearray":
[
{
year: 2013
},
{
year: 2012
},
{
year: 2011
},
{
year: 2010
}
]
}
The array "somearray" is sorted. Suppose if I update the second object {year : 2012}
to {year : 2014}
, is it possible to sort the array. the expected output after update is below:
{
_id: 1,
"somearray":
[
{
year: 2014
},
{
year: 2013
},
{
year: 2011
},
{
year: 2010
}
]
}
Could any one help.