title: How to use Lodash orderby with a custom function?
body: <p>I am using Lodash's <a href="https://lodash.com/docs/4.17.10#orderBy" rel="noreferrer">orderby</a> to sort a number of elements based on a key property.</p>
  
  <p>I want to prioritize them by another property (capacity) which is number from 0 to 9. Items with 0 capacity should be sorted at the end and all other items should be sorted by the key. </p>
  
  <p>So capacity property should be converted to a boolean value. I want to do this without changing the original object or adding a new property or making a new array.</p>
  
  <p>Sample data: </p>
  
  <pre><code>    [
        {
          "priceChild": 4098000,
          "priceAdult": 4098000,
          "priceInfant": 998000,
          "displayIndex": 4,
          "capacity": 5
        },
        {
          "priceChild": 3698000,
          "priceAdult": 3698000,
          "priceInfant": 898000,
          "displayIndex": 5,
          "capacity": 1
        },
        {
          "priceChild": 3006000,
          "priceAdult": 3980000,
          "priceInfant": 461000,
          "displayIndex": 6,
          "capacity": 0
        },
        {
          "priceChild": 4912000,
          "priceAdult": 6522000,
          "priceInfant": 715000,
          "displayIndex": 7,
          "capacity": 9
        }
      ]
  </code></pre>
  
  <p>This is the sort function that I am using right now:</p>
  
  <pre><code>orderBy(results, 'displayIndex', 'asc');
  </code></pre>
  
  <p>I want to do something like this but this code will not work because the ternary operator will not run for every item:</p>
  
  <pre><code>orderBy(results, [this.capacity === 0 ? true : false, 'displayIndex'], ['asc', 'asc']);
  </code></pre>