title: Sorting comma-separated strings of number
body: <p>I have some data that can be of the following format,</p>
  
  <pre><code> let items = [
    {
      number: "1"
    },
  
    {
      number: "5"
    },
  
    {
      number: "3,1"
    },
  
    {
      number: "3,11"
    },
  
    {
      number: "3,3"
    },
  
    {
      number: "3,2"
    }
  ]
  </code></pre>
  
  <p>I'd like to be able to sort it in the following precedence...
  1. By the 'number' value
      1. By the first "column" to the left of a possible comma in 'number'
      2. By whatever's to the right of a possible comma in the 'number' field</p>
  
  <p>Therefore, I'd expect to see "1" , "3,1", "3,2", "3,3", "3,11", "5"</p>
  
  <p>I'm using underscore to do the sorting and have came up with the following.</p>
  
  <pre><code>items = _.sortBy(items, function(item) {
    let sort = item.number;
  
    if (item.number.indexOf(",") != -1) {
      const split = item.number.split(",");
      sort = parseInt(split[0]);
    }
  
    return sort;
  });
  
  items = _.sortBy(items, function(item) {
    let sort = item.number;
  
    if (item.number.indexOf(",") != -1) {
      const split = item.number.split(",");
      sort = parseInt(split[1]);
    }
  
    return sort;
  });
  
  console.log(items);
  </code></pre>
  
  <p>That gives me "1" , "3,1", "3,2", "3,3", "5", "3,11" which is close but not quite right. Any ideas on how to solve this efficiently? (I know I can chain the sorts in underscore) I'm not partial to underscore and can use vanilla JS too</p>