title: How can I sort my Arraylist alphabetical? (Java)
body: <p>I am kind of new in java and I have not already a big knowledge about coding but maybe you can help me with my problem.
  I have a program  which should list all the songs in a alphabetical right order. I want to work with the Collections API. But in my code I don't get it right. Eclipse doesnt give me an error and on the emulator it runs, without to sort it right. Maybe you can show me, transferred to my code what I have to do, to get it running. Sorry for being not as good as you ;) ...But I am young and I want to learn all about coding.
  thanks a lot, Vinzenz :)</p>
  
  <pre><code>public class SongsManager {
  
  final String MEDIA_PATH = Environment.getExternalStorageDirectory()
          .getPath() + "/";
  private ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  private String mp3Pattern = ".mp3";
  private String mp4Pattern = ".mp4";
  private String MP3Pattern = ".MP3";
  private String MP4Pattern = ".MP4";
  private String m4aPattern = ".m4a";
  
  // Constructor
  public SongsManager() {
  
  }
  
  /**
   * Function to read all mp3 files and store the details in
   * ArrayList
   * */
  public ArrayList&lt;HashMap&lt;String, String&gt;&gt; getPlayList() {
      System.out.println(MEDIA_PATH);
      if (MEDIA_PATH != null) {
          File home = new File(MEDIA_PATH);
          File[] listFiles = home.listFiles();
          if (listFiles != null &amp;&amp; listFiles.length &gt; 0) {
              for (File file : listFiles) {
                  System.out.println(file.getAbsolutePath());
                  if (file.isDirectory()) {
                      scanDirectory(file);
                  } else {
                      addSongToList(file);
                  }
              }
          }
  
      }
      // return songs list array
      return songsList;
  
  
  
  }
  
  private void scanDirectory(File directory) {
      if (directory != null) {
          File[] listFiles = directory.listFiles();
          if (listFiles != null &amp;&amp; listFiles.length &gt; 0) {
              for (File file : listFiles) {
                  if (file.isDirectory()) {
                      scanDirectory(file);
                  } else {
                      addSongToList(file);
  
                  }
  
              }
          }
      }
  }
  
  private void addSongToList(File song) {
      if (song.getName().endsWith(mp3Pattern) || song.getName().endsWith(mp4Pattern) || song.getName().endsWith(MP4Pattern) || song.getName().endsWith(MP3Pattern) || song.getName().endsWith(m4aPattern)) {
          HashMap&lt;String, String&gt; songMap = new HashMap&lt;String, String&gt;();
          songMap.put("songTitle",
                  song.getName().substring(0, (song.getName().length() - 4)));
          songMap.put("songPath", song.getPath());
  
          // Adding each song to SongList
          songsList.add(songMap);
      }
  }
  
  public static void main (String[] args) {
      List&lt;String&gt; songsList = new LinkedList &lt;String&gt;();
      System.out.println(songsList);
      Collections.sort(songsList);
      System.out.println(songsList);
  
  }
  
  
  
  }
  </code></pre>