title: Comparing two lists by object fields
body: <p>I have two lists of Student objects. A student object is as follows:</p>
  
  <pre><code>Student
  int id
  int class id
  String name
  int age
  </code></pre>
  
  <p>In one list, I have student objects with the classId, name and age fields populated. I then insert them into a database which returns a collection of those same objects with the id populated with the integer assigned by the db schema. I wish to equate these two lists as best as possible to ensure the db operation was successful. I can think of two ways to do this. Either equate all student objects in the input list and output lists using all fields except id. Or, manually injecting the id of each student in the input list with the output list's values. Both ways are pretty unclean in their implementation so I was hoping there was a clean way to do it? For example, in the first option I can sort both the input and output collections, then iterate the first collection and compare with an index into the output collection for each field.</p>