How to sort objects list based on integer variable in Java : <p>I have a list of the following bean. I need to sort this list based on the version number of the object. I am new to Comparator interface and need some help here.</p>

<p>My POJO looks like this - </p>

<pre><code>class File{
private int version;
private String fileName;
public getVersion();
public setVersion();
public setFileName();
public getFileName();
}
</code></pre>

<p>The class where I am getting the list - </p>

<pre><code>class Example{
public static void main(){
List&lt;Files&gt; files = new ArrayList&lt;Files&gt;();
files = getInfoFromDB();

// How to sort the files based on version variable here. I am new to use Comparator.
Collections.sort(files);

}
}
</code></pre>
