title: sort mongodb data based on array express react
body: <p>i have record in mongoose which kinda look like this(demo) -</p>
  <pre><code>{
      name:&quot;son&quot;,
      email:&quot;final@gmail.com&quot;,
      score:[40,100,30,5]
  }
  </code></pre>
  <p>my model is -</p>
  <pre><code>const uModel =  new Schema({
  name: {
      type: String,
      required: true,
      max: 20, 
  },
  email: {
      type: String,
      required: true,
      unique: true,
      max: 50,
      min: 6
  },
  password: {
      type: String,
      required: true,
      min: 6
  },
  profile:{
      type: String,
      default: ''
  },
  score:{
      type: Array
  }})
  </code></pre>
  <p>and here is my post method in express -</p>
  <pre><code>const getAllData = (req, res)=&gt;{
  userModel.find().sort({score: -1})
  .then(user =&gt;{
      res.status(200).json(user)
  
  })
  .catch(err=&gt;{
      res.status(200).json(err)
  })}
  </code></pre>
  <p>i have a dashboard and i want to show user with highest score(score is dynamic, changes all the time)
  what i want is to sort score array(descending order ) and then sort user based on highest score(descending order). two thing what i want but i have no idea how to do it.
  after sorting 0 index of score array should have the higher value and last index lowest.</p>
  <p><code>find().sort({})</code> does not work for me.</p>
  <p>is it possible or should i change my strategy if i should change then what could be better one ??
  thanks in advance</p>