i get data from json and put in the HashMap and show in ListView Now i want sort desc data in this HashMap and show in ListVeiw
this is part of my code
for(int i=0;i<jmsg.length();i++){
JSONObject c = jmsg.getJSONObject(i);
String id = c.getString(TAG_ID);
String name = c.getString(TAG_NAME);
String email = c.getString(TAG_EMAIL);
String subj = c.getString(TAG_SUBJ);
String text = c.getString(TAG_TEXT);
Log.i("Ekhteraat app ControlPanel", id);
HashMap<String,String> nnews = new HashMap<String,String>();
nnews.put(TAG_ID,id);
nnews.put(TAG_NAME,name);
nnews.put(TAG_EMAIL,email);
nnews.put(TAG_SUBJ,subj);
nnews.put(TAG_TEXT,text);
msgList.add(nnews);
nText=nText + subj + "\n";
tnews=tnews+1;
ListAdapter adapter = new SimpleAdapter(
GetMSGActivity.this, msgList, R.layout.list_item,
new String[]{TAG_ID,TAG_NAME,TAG_EMAIL,TAG_SUBJ,TAG_TEXT},
new int[]{R.id.id, R.id.name, R.id.email, R.id.subj, R.id.text}
);
list.setAdapter(adapter);
}
Can you please check how can sort it.
my data like this
id,1
name,sadegh
email,sadegh@email.com
subject,test
text,hi this is test
id,2
name,rrr
email,rrr@email.com
subject,test
text,hi this is test
id,3
name,lll
email,lll@email.com
subject,test
text,hi this is test
but i want show here
id,3
name,lll
email,lll@email.com
subject,test
text,hi this is test
id,2
name,rrr
email,rrr@email.com
subject,test
text,hi this is test
id,1
name,sadegh
email,sadegh@email.com
subject,test
text,hi this is test