title: Simple way to parse numbers as strings while sorting with Java streams?
body: <p>I have a list of objects that contain values stored as strings but are actually numbers and I'm trying to find a way to parse strings to integers within a Java stream to sort them numerically. Here's what I got so far.</p>
  
  <pre><code>List&lt;SearchResultObject&gt; returnedValues = doTheSearchMethod();
  returnedValues = returnedValues
  .stream()
  .sorted(Comparator.comparing(SearchResultObject::getNumber))
  .collect(Collectors.toList());
  </code></pre>
  
  <p>As of right now this kind of works, but the problem is that because those numbers are actually strings, it sorts the numbers lexicographically, not numerically. Is there a way to incorporate parsing into the stream? All numbers are padded to be the same size.</p>
  
  <pre><code>3356001017053000000000000
  3356001017002000000000000
  3356001017004000000000000
  3356001017026000000000000
  5101004003020000000000000
  4123000006002510000000000
  4758000005010000000000000
  </code></pre>