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:anslab2.Test.java
public static ArrayList sortData(ArrayList toSort, int dataType) { n = toSort.size();/*from w w w . j a v a2 s . c o m*/ if (dataType == 1) { ArrayList<String> alphabetic = new ArrayList<String>(); for (Object data : toSort) { ; alphabetic.add(String.valueOf(data)); } Collections.sort(alphabetic); labels = alphabetic; return alphabetic; } else if (dataType == 2) { ArrayList<Double> numeric = new ArrayList<Double>(); for (Object data : toSort) { numeric.add(Double.valueOf(String.valueOf(data))); } Collections.sort(numeric); labelsD = numeric; return numeric; } else if (dataType == 3) { ArrayList<String> string = new ArrayList<String>(); for (Object data : toSort) { string.add(String.valueOf(data)); } Collections.sort(string); labels = string; return string; } return null; }
From source file:au.org.ala.delta.intkey.model.FormattingUtils.java
/** * Formats the values set for an integer character as a string. It is * assumed the values for the integer character have already been processed * such that they are in the range minimumValue - 1 to maximumValue + 1. * //w w w .j av a2s.co m * @param integerValues * the values set for the integer character * @param minimumValue * the character's minimum value * @param maximumValue * the character's maximum value * @return the integer character's values formatted as a string. */ public static String formatIntegerValuesAsString(Set<Integer> integerValues, int minimumValue, int maximumValue) { Set<Integer> valuesCopy = new HashSet<Integer>(integerValues); List<String> stringParts = new ArrayList<String>(); if (integerValues.contains(minimumValue - 1)) { stringParts.add(Integer.toString(minimumValue - 1)); } valuesCopy.remove(minimumValue - 1); valuesCopy.remove(maximumValue + 1); if (!valuesCopy.isEmpty()) { List<Integer> valuesCopyAsList = new ArrayList<Integer>(valuesCopy); Collections.sort(valuesCopyAsList); stringParts.add(Utils.formatIntegersAsListOfRanges(valuesCopyAsList, "/", "-")); } if (integerValues.contains(maximumValue + 1)) { stringParts.add(Integer.toString(maximumValue + 1)); } return StringUtils.join(stringParts, "/"); }
From source file:com.github.blindpirate.gogradle.util.CollectionUtils.java
public static <T extends Comparable<? super T>> List<T> toSorted(Collection<T> c) { List<T> ret = new ArrayList<>(c); Collections.sort(ret); return ret;/* w w w .ja v a 2 s . co m*/ }
From source file:com.ibk.ltw.repository.ProductRepository.java
public ProductRepository() { products.add(new Product("2 oz. Bees Wax", 450)); products.add(new Product("5 oz. Bees Wax", 900)); products.add(new Product("1 lb. Pure Local Raw Honey", 800)); products.add(new Product("3 lb. Pure Local Raw Honey", 180)); Collections.sort(products); }
From source file:Main.java
public static <T extends Comparable<T>> List<T> sort(List<T> list) { Collections.sort(list); return (list); }
From source file:hudson.plugins.plot.PlotReport.java
public PlotReport(AbstractProject<?, ?> project, String group, List<Plot> plots) { Collections.sort(plots); this.plots = plots; this.group = group; this.project = project; }
From source file:GUI.GraficaView.java
private void init() { ArrayList<OperacionesDiarias> aux = operario.getArrayOperacionesDiarias(); Collections.sort(aux); panel = new JPanel(); getContentPane().add(panel);// ww w. jav a 2 s .com // Fuente de Datos DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (OperacionesDiarias op : aux) { if (op.getListaOperaciones().size() > 0) { dataset.setValue(op.getPorcentaje(), operario.getNombre(), op.getFecha()); } } // Creando el Grafico JFreeChart chart = ChartFactory.createBarChart3D("Rendimiento", "Dia", "Porcentaje %", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.LIGHT_GRAY); chart.getTitle().setPaint(Color.black); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); // Mostrar Grafico ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); repaint(); }
From source file:com.eyem.services.PostService.java
public List<Post> buscarPostGrupo(Long idGrupo) { List<Post> res = postRepository.buscarPostGrupo(idGrupo.toString()); if (res.isEmpty() || res.size() <= 0) { return null; } else {// w w w. j av a 2s. c o m Collections.sort(res); return res; } }
From source file:org.zlogic.vogon.web.controller.CurrenciesController.java
/** * Creates the wrapped currency list/*from ww w .ja va 2s . com*/ * * @return the wrapped currency list */ @Bean public Collection<CurrencyDetails> currencies() { List<CurrencyDetails> currencies = new ArrayList<>(); for (Currency currency : Currency.getAvailableCurrencies()) currencies.add(new CurrencyDetails(currency)); Collections.sort(currencies); return currencies; }
From source file:com.skelril.nitro.point.ValueMapping.java
public ValueMapping(List<PointValue<KeyType, PointType>> values, PointType zeroValue, PointType oneValue, BiFunction<PointType, PointType, PointType> pointTypeDiv, BiFunction<PointType, PointType, PointType> pointTypeMod) { this.values = new ArrayList<>(values); this.zeroValue = zeroValue; this.oneValue = oneValue; this.pointTypeDiv = pointTypeDiv; this.pointTypeMod = pointTypeMod; Collections.sort(this.values); Validate.isTrue(!this.values.isEmpty() && this.values.get(0).getPoints().compareTo(zeroValue) > 0); for (PointValue<KeyType, PointType> pointVal : this.values) { for (KeyType satisfier : pointVal.getSatisfiers()) { valueMap.put(createIndexOf(satisfier), pointVal); }//from www.j a v a2 s . com } }