java - how to sort String array Number and bind in array list in android -


 list<string> list2 =new arraylist<string>();  int iarr[] = new int[ja.length()];//{"846001","846005","846000","846002","846009"}  arrays.sort(iarr);  (int = 0; < ja.length(); i++) {       _jobject = ja.getjsonobject(i);       iarr[i] = integer.parseint(_jobject.getstring("pincode"));  }  for(int k=0;k<iarr.length;k++) {      list2.add(string.valueof(iarr[k]));  }  

i want sort , bind in array list. want

{"846000", "846001", "846002" ,"846005", "846009"}

but not sorting according given logic please suggest me doing wrong.

i think issue sorting array before manipulating it. should move arrays.sort(iarr) after for loop.

list<string> list2 =new arraylist<string>(); int iarr[] = new int[ja.length()];//{"846001","846005","846000","846002","846009"}  (int = 0; < ja.length(); i++) {     _jobject = ja.getjsonobject(i);     iarr[i] = integer.parseint(_jobject.getstring("pincode")); } arrays.sort(iarr); for(int k=0;k<iarr.length;k++) {     list2.add(string.valueof(iarr[k])); } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -