title: Sort adapter in android
body: <p>I would like to know how I can sort this adapter:</p>
  
  <pre><code>private class ProductsListAdapter extends BaseAdapter {
  
          public ProductsListAdapter() {
              super();
  
          }
  
          public int getCount() {
              return SingletonComparer.getInstance().getProducts().size();
          }
  
          public Object getItem(int position) {
              return SingletonComparer.getInstance().getProducts().get(position);
          }
  
          public long getItemId(int position) {
              return SingletonComparer.getInstance().getProducts().get(position).getId();
          }
  
          public View getView(int position, View convertView, ViewGroup parent) {
                  TextView textView = getGenericView();
                  textView.setText(SingletonComparer.getInstance().getProducts().get(position)
                          .getName());
                  TextView textView2 = getGenericView();
                  textView2.setText(""
                          + SingletonComparer.getInstance().getProducts()
                                  .get(position).getPrice());
                  TextView textView3 = getGenericView();
  
  
                  textView3.setText(SingletonData.getInstance().getBrandName(SingletonComparer.getInstance().getProducts().get(position)
                          .getBrandID()));
  
                  LinearLayout ll = new LinearLayout(getActivity());
                  ll.addView(textView, new LinearLayout.LayoutParams(0,
                          LayoutParams.WRAP_CONTENT, 1.0f));
                  ll.addView(textView2, 1, new LinearLayout.LayoutParams(0,
                          LayoutParams.WRAP_CONTENT, 1.0f));
                  ll.addView(textView3, 2, new LinearLayout.LayoutParams(0,
                          LayoutParams.WRAP_CONTENT, 1.0f));
                  ll.setId(SingletonComparer.getInstance().getProducts().get(position)
                          .getId());
                  return ll;
  
          }
      }
  </code></pre>
  
  <p>by field </p>
  
  <pre><code>SingletonComparer.getInstance().getProducts()
                                      .get(position).getPrice());
  </code></pre>
  
  <p>This is possible? If yes How I can do that?</p>