title: Sorting of objects in an array by integer property value
body: <p>There is an array which looks like this:</p>
  
  <pre><code>[
    { 
      _id: 'xxnQt5X8pfbcJMn6i',
      order: 2
    },
    { 
      _id: 'X8pfbcJxxnQt5Mn6i',
      order: 1
    },
    { 
      _id: 'Qt5X8pfxxnbcJMn6i',
      order: 3
    }
  ]
  </code></pre>
  
  <p>Now I need to sort the objects of this array by the <code>order</code> value. I tried to do this:</p>
  
  <pre><code>array.sort((a, b) =&gt; {
    return (a.order &gt; b.order)
      ? 1
      : (b.order &gt; a.order)
        ? -1
        : 0
  })
  </code></pre>
  
  <p>But first it looks to me a bit to complicated for just sorting by an integer value and second it gives me the error <code>TypeError: Cannot assign to read only property '1' of object '[object Array]'</code></p>