java ArrayList 정렬 질문

h2ogid의 이미지

아래 코드의 결과가

1.aaa
3.aaa
4.aaa
2.aaa
6.aaa
5.aaa

라고 했을 때 이를
1.aaa
2.aaa
3.aaa
4.aaa
5.aaa
6.aaa

으로 정렬 하여 출력 하고 싶습니다.

도와 주세요

------

package test_sum;

import java.io.*;
import java.util.*;

public class test_sum_process {

public static void main(String[] args) throws IOException,FileNotFoundException{
Scanner dateinput = new Scanner(System.in); // script parameter -- date values
String stat_date = dateinput.next();

ArrayList txtFiles= new ArrayList();
File f= new File("D:/AADEV_LGE/workspace/test_stat_sum/rsc"); // Log Dir
String tmpFile = f+"/tmp"; // Temp File
String result = f+"/result.txt"+"_"+stat_date; // Result File

if(!f.exists())
{
System.out.println("not found dir");
return;
}

File[] allFiles= f.listFiles();
for(File file : allFiles)
{
if(file.getName().startsWith(stat_date))
{
txtFiles.add(file);

}
}

for(File file : txtFiles)
{
String readFile = f+"/"+file.getName();

try {
BufferedReader in = new BufferedReader(new FileReader(readFile));
//System.out.println(readFile);
String line = "";
while ((line = in.readLine()) != null) {

if (line.indexOf(":") < 0)
continue;
// System.out.println(line);
String[] arr = line.split(":");

String codetmp = arr[0] ;

String cnttmp = arr[1] ;

String codename = codetmp.replaceAll("[- ]", "");
String codecnt = cnttmp.replaceAll("[^0-9.-]", "");


BufferedWriter out = new BufferedWriter(new FileWriter(tmpFile,true));
StringBuffer str1 = new StringBuffer(codename);
StringBuffer str2 = new StringBuffer(codecnt);

out.write(str1 + " " + str2 + "\n");
out.flush();
}
in.close();

} catch (IOException e) {
System.out.println(e);
}
}
Scanner in2 = new Scanner(new File(tmpFile));

HashMap map = new HashMap();
HashMap map2 = new HashMap();
ArrayList order = new ArrayList();
ArrayList order2 = new ArrayList();


String cntname;
Double logcnt;

while (in2.hasNext()) {


cntname = in2.next();
logcnt = in2.nextDouble();

if (cntname.equals("FirstLog") || cntname.equals("LastLog")) {
System.out.println("");
}
else if (!cntname.equals("90%응답시간")) {

if (!map.containsKey(cntname)) {
LogList s = new LogList(cntname, logcnt);
order.add(s);
map.put(cntname, s); // 사용자를 기억해놓습니다
}
map.get(cntname).addScore(logcnt);
}
else if (cntname.equals("90%응답시간")) {
if (!map2.containsKey(cntname)) {
LogList2 s = new LogList2(cntname, logcnt);
order2.add(s);
map2.put(cntname, s); // 사용자를 기억해놓습니다
}
map2.get(cntname).addScore2(logcnt);
}

}

try {
PrintWriter out = new PrintWriter(new FileWriter(result, true));

for(LogList i : order ) // class 에서 리턴 시 번호를 붙임
out.println(i);


for(LogList2 i : order2 )
out.println(i);
out.close();

} catch (Exception e) {

if(e instanceof IOException) System.out.println("Input & Out Error ");
else System.out.println("Etc Error " + e.toString());
}
}

}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.