I have setup a firebase database and I was wondering how I'd make it so that my listView shows my data in ascending or descending order.
For example: if I wanted something thats the most expensive I'd have it at the top of my listView and the cheaper ones at the bottom.
Basically I'm trying to create a ranking activity where I've two seperate listviews that rank by cost and count individually.
This is what I have for my count:
  @Override
    protected void onStart() {
        super.onStart();
        itemlists=new ArrayList<String>();
        databaseItems.child("items").addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for (DataSnapshot itemSnapShot : dataSnapshot.getChildren()) {
                    String itemname=itemSnapShot.child("itemName").getValue().toString();
                    itemlists.add(itemname);
                    adapter = new ArrayAdapter(SearchActivity.this,android.R.layout.simple_list_item_1,itemlists);
                    listFinalCount.setAdapter(adapter);
                }
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
    }

 
     
     
     
    