title: Android sort ListView alphabetically
body: <p>So I'm trying to sort a simple <code>ArrayAdapter</code> for ListView. Here's what I've tried:</p>
  
  <pre><code>ListView lv;
  String[] months = {
          "January",
          "February",
          "March",
          "April",
          "May",
          "June",
          "July",
          "August",
          "September",
          "October",
          "November",
          "December"
  };
  
  ArrayAdapter&lt;String&gt; adapter;
  ArrayList&lt;String&gt; list;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      lv = (ListView) findViewById(R.id.listView1);
      lv.setFastScrollEnabled(true);
      adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, months);
      lv.setAdapter(adapter);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // TODO Auto-generated method stub
  
      switch (item.getItemId()) {
          case R.id.sortasc:
              list = new ArrayList&lt;String&gt;(Arrays.asList(months));
              Collections.sort(list);
              for (int i = 0; i &lt; list.size(); i++) {
                  System.out.println(list.get(i));
              }
              adapter.clear();
              adapter = new ArrayAdapter&lt;String&gt;(this,
                      android.R.layout.simple_list_item_1, list);
              adapter.notifyDataSetChanged();
              return true;
          case R.id.sortdesc:
  
              return true;
          default:
              return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>But I'm getting <code>UnsupportedOperationException</code>, what's wrong with this? I really need help. Thanks in advance!</p>