Sorting An Array of Pairs By The First Value in Java
<p>I have a simple pair class and have created an array of them.</p>

<pre><code>private static class Pair
{
    private String l;
    private String e;
}
</code></pre>

<p>I was wondering if it's possible to sort an array of pairs such as: 
<code>(a, de), (g, e), (dde, gh)</code>
by just first element in the pair. Creating a result of: <code>(a, de), (dde, gh), (g,e)</code> I know this is possible in c++, but I'm new to Java and have been searching online for hours for a solution. I've read that you can use Comparator, but am still not sure how that really works. Any suggestions would be very much appreciated. Thanks!</p>