By default sort
uses the cmp
operator to compare elements,
which does a string comparison. In ASCII order, "10" comes
before "8", which is why you are getting those results. As
pointed out, you have to instruct the <=>
to make it compare things as numbers.