title: Find unique records from list based on latest timestamp in java
body: <p>I have a list contains list of object with duplicates and only differs on timestamp and I need to get latest timestamp value. </p>
  
  <p>I am adding some mock data similar to my case</p>
  
  <pre><code>List&lt;Person&gt; personList = new ArrayList&lt;&gt;();
  personList.add( new Person( name1,created, 1563428880 ));
  personList.add( new Person( name2,created, 1563428880 ));
  personList.add( new Person( name3,created, 1563428880 ));
  personList.add( new Person( name2,updated, 1563429998 ));
  personList.add( new Person( name3,updated, 1563429998 ));
  </code></pre>
  
  <p>I have below code to get the unique object from the list</p>
  
  <pre><code>for (Person person: personList) {
      if(uniqueLatestPersonMap.containsKey( person.getName() )) {
          Person availablePerson = uniqueLatestPersonMap.get(person.getName());
          int status = availablePerson.getTimestamp().compareTo(person.getTimestamp());
          if(status  == -1) {
              uniqueLatestPersonMap.put(person.getName(),person); 
          }
      } else {
          uniqueLatestPersonMap.put(person.getName(),person);
      }
  }
  </code></pre>
  
  <p>Because of my large data and response time not as we are expected. Is there any way we can improve the response time or any alter way to do it efficiently.</p>
  
  <p>My output list will have the </p>
  
  <pre><code>Person( name1,created, 1563428880 )
  Person( name2,updated, 1563429998 );
  Person( name3,updated, 1563429998 );
  </code></pre>
  
  <p>Thanks in advance to all.</p>