Sorter.java [Last ned]

import java.util.*;
import static java.lang.System.*;
 
public class Sorter {
 
  public static void main(String[] args) {
 
    final int MAX = 100;
    String[] dataTab = new String[MAX];
    Scanner stdin = new Scanner(System.in);
    int pos = 0;
 
    while ( stdin.hasNextLine() && pos<MAX )
      dataTab[pos++] = stdin.nextLine();
 
    Arrays.sort(dataTab, 0, pos);
 
    for (int i=0; i<pos; i++)
      out.println(dataTab[i]);
  }
 
}
Kildekode blir vist ved hjelp av GeSHi.