Here you can find the source of sortList(ArrayList list)
public static ArrayList sortList(ArrayList list)
//package com.java2s; /******************************************************************************* * Copyright ? 2001, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //from w ww .ja va2 s . c o m * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.Arrays; public class Main { /** Sorts a given ArrayList. */ public static ArrayList sortList(ArrayList list) { Object[] a = list.toArray(); Arrays.sort(a); list.clear(); for (int i = 0; i < a.length; i++) list.add(a[i]); return list; } }