how to do sorting using java

Posted by karthikacyr on Stack Overflow See other posts from Stack Overflow or by karthikacyr
Published on 2010-05-31T08:40:04Z Indexed on 2010/05/31 8:42 UTC
Read the original article Hit count: 143

Filed under:

hi friends, I have text file with list of alphabets and numbers. I want to do sorting w.r.t this number using java. My text file looks like this: a--->12347 g--->65784 r--->675 I read the text file and i split it now. But i dont know how to perform sorting . I am new to java. Please give me a idea. My output want to be g--->65784 a--->12347 r--->675 Plese help me. Thanks in advance. My coding is String str = ""; BufferedReader br = new BufferedReader(new FileReader("counts.txt")); while ((str = br.readLine()) != null) { String[] get = str.split("---->>"); When i search the internet all suggest in the type of arrays. I tried. But no use.How to inlude the get[1] into array. int arr[]=new int[50] arr[i]=get[1]; for(int i=0;i<50000;i++){ for(int j=i+1;j<60000;j++){ if(arr[i]>arr[j]){ System.out.println(arr[i]); } }

© Stack Overflow or respective owner

Related posts about java