i want to change trending position based on views if there is any way to do this via sort function in node js.
var data = [
{
trending:1,
views:10
},
{
trending:2,
views:20
},{
trending:3,
views:30
},
]
data.sort((a, b) => b.views - a.views)
sort function only change the order but i want to change trending position when sorting.