Here you can find the source of sortByLength(String[] proposals)
private static String[] sortByLength(String[] proposals)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2010 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 * * Contributors:/* w ww .j a v a 2 s. co m*/ * IBM Corporation - initial API and implementation * John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class *******************************************************************************/ import java.util.Arrays; import java.util.Comparator; public class Main { private static String[] sortByLength(String[] proposals) { Arrays.sort(proposals, new Comparator() { public int compare(Object o1, Object o2) { return ((String) o2).length() - ((String) o1).length(); } }); return proposals; } }