import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

class A {
    public static void main(String[] args) throws Exception {
        List<Integer> l = new ArrayList<Integer>();
        l.add(new Integer(3));
        l.add(new Integer(2));
        l.add(new Integer(1));
        l.add(new Integer(5));
        l.add(new Integer(4));

        Object[] o = l.toArray();

        Arrays.sort(o,new Comparator<object>() {
            public int compare(Object o1, Object o2) {
                return ((Integer)o1).intValue() - ((Integer)o2).intValue();

                // 降順の場合は以下
                // return ((Integer)o2).intValue() - ((Integer)o1).intValue();
            }
        });

        for(Object v : o) {
            System.out.println(((Integer)v).intValue());
        }
    }
}