Java List Sort sortList(ArrayList list)

Here you can find the source of sortList(ArrayList list)

Description

Sorts a given ArrayList.

License

Open Source License

Declaration

public static ArrayList sortList(ArrayList list) 

Method Source Code

//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;
    }
}

Related

  1. sortEntrySetToList(Set> set)
  2. sortIds(List ids)
  3. sortIfUnsorted(List genomes)
  4. sortInputQueryKeys(List l)
  5. sortItems(List items, String putOnTop)
  6. sortList(Collection list)
  7. sortList(java.util.List types)
  8. sortList(List list)
  9. sortList(List items)