title: Sorting objects in specific order after sorting by integer value
body: <p>I am currently trying to sort an array of objects into a specific order.</p>
  
  <p>I currently sort it by levels - which works fine, but then I need to have it ordered as shown below where "Concatenator" type must can only come after and before a "Clause" type as seen below:</p>
  
  <pre><code>[
    {
      "type": "Clause",
      "level": 1
    },
    {
      "type": "Concatenator",
      "level": 1
    },
    {
      "type": "Clause",
      "level": 2
    },
    {
      "type": "Concatenator",
      "level": 2
    },
    {
      "type": "Clause",
      "level": 2
    },
    {
      "type": "Concatenator",
      "level": 3
    },
    {
      "type": "Clause",
      "level": 3
    },
    {
      "type": "Concatenator",
      "level": 3
    },
    {
      "type": "Clause",
      "level": 3
    },
    {
      "type": "Concatenator",
      "level": 4
    },
    {
      "type": "Clause",
      "level": 4
    },
    {
      "type": "Concatenator",
      "level": 4
    },
    {
      "type": "Clause",
      "level": 4
    }
  ]
  </code></pre>
  
  <p>Below is the code I currently have where it currently sorts just by level and an attempt to sort it how I want:</p>
  
  <pre><code>conditionsArr = [{
      "type": "Concatenator",
      "level": 3
    },
    {
      "type": "Clause",
      "level": 4
    },
    {
      "type": "Clause",
      "level": 1
    },
    {
      "type": "Concatenator",
      "level": 1
    },
    {
      "type": "Clause",
      "level": 3
    },
    {
      "type": "Clause",
      "level": 4
    },
    {
      "type": "Clause",
      "level": 3
    },
    {
      "type": "Concatenator",
      "level": 4
    },
    {
      "type": "Clause",
      "level": 2
    },
    {
      "type": "Concatenator",
      "level": 2
    },
    {
      "type": "Concatenator",
      "level": 3
    },
    {
      "type": "Clause",
      "level": 2
    },
    {
      "type": "Concatenator",
      "level": 4
    }
  ]
  
  
  function sortByLevel(conditionsArr) {
    return conditionsArr.sort(function(a, b) {
      return a.level - b.level;
    }).sort(function(a, b) {
      if (a.type === b.type)
        return -1;
      return 0;
    });
  }
  </code></pre>
  
  <p>I have tried doing another sort, and looked at other answers for inspiration but I have not been able to get it into the order I need for the second half of the sorting.</p>
  
  <p>Is there any suggestions on how I can sort it like that?</p>