List of usage examples for java.util Collections sort
@SuppressWarnings("unchecked") public static <T extends Comparable<? super T>> void sort(List<T> list)
From source file:dk.frankbille.scoreboard.domain.TeamResult.java
public TeamResult(TeamId team, Set<Player> players) { this.team = team; List<String> names = new ArrayList<String>(); for (Player player : players) { names.add(player.getName());/*from w w w . j a va 2 s . c om*/ } Collections.sort(names); this.name = StringUtils.join(names, ", "); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.json.GetAllVClasses.java
@Override protected JSONObject process() throws Exception { JSONObject map = new JSONObject(); //Get all VClassGroups List<VClass> vclasses = new ArrayList<VClass>(); VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq); List<VClassGroup> groups = vcgc.getGroups(); for (VClassGroup vcg : groups) { for (VClass vc : vcg) { vclasses.add(vc);/* ww w .j a v a2s . c om*/ } } //Sort vclass by name Collections.sort(vclasses); ArrayList<JSONObject> classes = new ArrayList<JSONObject>(vclasses.size()); for (VClass vc : vclasses) { JSONObject vcObj = new JSONObject(); vcObj.put("name", vc.getName()); vcObj.put("URI", vc.getURI()); classes.add(vcObj); } map.put("classes", classes); return map; }
From source file:org.activiti.rest.service.api.legacy.management.TablesResource.java
@Get public ObjectNode getTables() { if (authenticate(SecuredResource.ADMIN) == false) return null; Map<String, Long> tableCounts = ActivitiUtil.getManagementService().getTableCount(); ArrayList<String> tableNames = new ArrayList<String>(tableCounts.keySet()); Collections.sort(tableNames); ObjectNode responseJSON = new ObjectMapper().createObjectNode(); ArrayNode tablesJSON = new ObjectMapper().createArrayNode(); responseJSON.put("data", tablesJSON); for (String tableName : tableNames) { ObjectNode tableJSON = new ObjectMapper().createObjectNode(); tableJSON.put("tableName", tableName); tableJSON.put("total", tableCounts.get(tableName)); tablesJSON.add(tableJSON);// w ww .java2s .c o m } return responseJSON; }
From source file:nl.ordina.bag.etl.util.Log4jUtils.java
public static String[] getLoggers() { ArrayList<String> result = new ArrayList<String>(); for (@SuppressWarnings("unchecked") Enumeration<Logger> loggers = LogManager.getCurrentLoggers(); loggers.hasMoreElements();) { Logger logger = loggers.nextElement(); result.add(logger.getName() + ": " + logger.getLevel()); }/*w w w . ja v a 2s. c o m*/ Collections.sort(result); return result.toArray(new String[0]); }
From source file:net.sf.click.jquery.examples.services.PostCodeService.java
public List<String> getPostCodeLocations(String location) { List<String> list = new ArrayList<String>(); for (PostCode postCode : getPostCodes()) { if (StringUtils.startsWithIgnoreCase(postCode.getLocality(), location)) { String value = postCode.getLocality() + ", " + postCode.getState() + " " + postCode.getPostCode(); list.add(value);//from w w w . j a v a 2 s .c o m } } Collections.sort(list); return list; }
From source file:Main.java
public static <T extends Comparable<T>> Collection<T> sort(Collection<T> items) { List<T> list = new ArrayList<T>(items); Collections.sort(list); return (list); }
From source file:Main.java
public SortedComboBoxModel(Vector items) { Collections.sort(items); int size = items.size(); for (int i = 0; i < size; i++) { super.addElement(items.elementAt(i)); }// w w w .j a va 2 s . co m setSelectedItem(items.elementAt(0)); }
From source file:com.liveramp.cascading_ext.counters.Counters.java
public static Map<FlowStepStats, List<Counter>> getCountersByStep(FlowStats flowStats) { Map<FlowStepStats, List<Counter>> counters = new HashMap<FlowStepStats, List<Counter>>(); for (FlowStepStats statsForStep : flowStats.getFlowStepStats()) { if (!counters.containsKey(statsForStep)) { counters.put(statsForStep, Lists.<Counter>newArrayList()); }//from w ww . j av a 2s .c om counters.get(statsForStep).addAll(getStatsFromStep(statsForStep, null)); } for (Map.Entry<FlowStepStats, List<Counter>> entry : counters.entrySet()) { Collections.sort(entry.getValue()); } return counters; }
From source file:com.egt.ejb.toolkit.ColUtils.java
public static Collection sort(Collection collection) { if (collection instanceof List) { List list = (List) collection; Collections.sort(list); }/*from w w w. ja v a 2s. c o m*/ return collection; }
From source file:com.intuit.tank.vm.settings.ProductConfig.java
@SuppressWarnings("unchecked") private void initConfig() { products = new ArrayList<SelectableItem>(); if (config != null) { List<HierarchicalConfiguration> productEntries = config.configurationsAt(KEY_PRODUCT); for (HierarchicalConfiguration c : productEntries) { products.add(new SelectableItem(c.getString(""), c.getString("@name"))); }/*from www. j a v a2 s . com*/ } Collections.sort(products); }