title: Is this the best way to write this non-numerical/alphabetical sort?
body: <p>I have various styles of font objects grouped into arrays. Each font object has a property sub_family which is either Regular, Italic, Bold, Bold Italic (or some variation e.g. Italic is sometimes called Oblique). When they come out of the database they are in a random order and need to be sorted as above; Regular is always first, Italic second, etc.</p>
  
  <p>Here's the sort function I'm using, it works but I wanted to see if you guys could come up with better/alternate solutions:</p>
  
  <pre><code>// input: ["Bold Italic", "Regular", "Bold", "Italic"]    
  sortFont = function(a, b) {
      // regular
      if (/^([Rr]egular|[Nn]ormal)$/.test(a.sub_family)) { return -1; }
      if (/^([Rr]egular|[Nn]ormal)$/.test(b.sub_family)) { return 1; }
      // italic
      if (/^([Ii]talic|[Ii]nclined|[Ii]t|[Oo]blique|[Oo]bl)$/.test(a.sub_family)) { return -1; }
      if (/^([Ii]talic|[Ii]nclined|[Ii]t|[Oo]blique|[Oo]bl)$/.test(b.sub_family)) { return 1; }
      // bold
      if (/^([Bb]old|[Bb]d)$/.test(a.sub_family)) { return -1; }
      if (/^([Bb]old|[Bb]d)$/.test(b.sub_family)) { return 1; }
  }
  // output: ["Regular", "Italic", "Bold", "Bold Italic"]
  </code></pre>
  
  <p>thanks! :)</p>