lodash SortBy object content
<p>I have an array of objects like so:</p>

<pre><code>var quantityPricing = [ 
    { quantity: 1, cost: 0.5 }, 
    { quantity: 100, cost: 0.45 }, 
    { quantity: 1000, cost: 0.25 }, 
    { quantity: 500, cost: 0.35 }
];
</code></pre>

<p>I am trying to sortBy the content of this array in ascending order based on the quantity, so the result I am expecting should be:</p>

<pre><code>[
    { quantity: 1, cost: 0.5 },
    { quantity: 100, cost: 0.45 },
    { quantity: 500, cost: 0.35 },
    { quantity: 1000, cost: 0.25 }
]
</code></pre>

<p>I have therefore tried to use the lodash command: </p>

<pre><code>_.sortBy(quantityPricing, ['quantity']);
</code></pre>

<p>But unfortunately the result which is returned by the function seem to be only sorted by the first digit in the quantity, for example: </p>

<pre><code>{
    "quantity": 1,
    "cost": 0.5
},
{
    "quantity": 100,
    "cost": 0.45
},
{
    "quantity": 1000,
    "cost": 0.25
},
{
    "quantity": 500,
    "cost": 0.35
}
</code></pre>

<p>I do not understand why 500 comes at the end, unless it is sorting by the first digit only? As 500 should come after 100 once my array is sorted.</p>

<p>Any help would be greatly appreciated.</p>