title: Unit test of a list sorting implementation?
body: <p>I am currently writing a unit test that is checking if a method is correctly sorting a list.</p>
  
  <p>The sorting method is overrding a <code>compare</code> method from the clas <code>Comparator</code> and is sorting the list using <code>Collections.sort()</code>.</p>
  
  <p>It may not be a technical question, but I am looking for a way to use JUnit's assertions to check if the list is correctly sorted...</p>
  
  <p>The list is sorted by an inner parameter of the type it is holding, let me call it <code>id</code>. So when the list contains 3 items with ID's: 3,1,2 - it shall sort them as 1,2,3.</p>
  
  <pre><code>Long expected1 = listOfObjects.get(0).getId()
  Long expected2 = listOfObjects.get(1).getId()
  Long expected3 = listOfObjects.get(2).getId()
  </code></pre>
  
  <p>And then using asserions on those Long objects ain't looking clean nor clever. I am looking for an idea how to cleanly and cleverly test this case, but I'm out of ideas...</p>