a.sort(function(a,b){return a - b})

These can be confusing.... check this link out.