I need items in my ListView with more likes to appear first in my feed, how do I do this? follows image of firebase structure
MyAdapter
@NonNull@OverridepublicViewgetView(finalintposition,@NullableViewconvertView,@NonNullViewGroupparent){LayoutInflaterinflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);autenticacao=FirebaseAuth.getInstance();@SuppressLint("ViewHolder") View v =
inflater.inflate(R.layout.image_item, parent, false);
imgList = new ArrayList<>();
mDatabaseRef =
FirebaseDatabase.getInstance().getReference("videos/");
Query myTopPostsQuery = mDatabaseRef.orderByChild("videos");
myTopPostsQuery.addValueEventListener(new ValueEventListener()
{
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Fetch image data from firebase database
for (DataSnapshot snapshot :
dataSnapshot.getChildren()) {
VideoUpload video =
snapshot.getValue(VideoUpload.class);
string = video.getUrl();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});