Here you can find the source of sortClustersKeys(final Map
Parameter | Description |
---|---|
clusters | Package cluster. |
private static List<String> sortClustersKeys(final Map<String, Set<String>> clusters)
//package com.java2s; /*//ww w .j a v a 2s . com * Copyright 2011 jccastrejon * * This file is part of Web2MexADL. * * Web2MexADL is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * Web2MexADL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with Web2MexADL. If not, see <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Set; public class Main { /** * Sort cluster keys by their packages size. * * @param clusters * Package cluster. * @return Sorted cluster keys. */ private static List<String> sortClustersKeys(final Map<String, Set<String>> clusters) { List<String> returnValue; returnValue = new ArrayList<String>(clusters.keySet()); Collections.sort(returnValue, new Comparator<String>() { public int compare(final String first, final String second) { return new Integer(clusters.get(first).size()).compareTo(clusters.get(second).size()); } }); return returnValue; } }