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:com.liferay.ide.core.util.FileListing.java
/** * Recursively walk a directory tree and return a List of all Files found; the * List is sorted using File.compareTo(). * * @param aStartingDir// w w w .j av a2 s . com * is a valid directory, which can be read. */ public static List<File> getFileListing(File aStartingDir, boolean sort) throws FileNotFoundException { _validateDirectory(aStartingDir); List<File> result = getFileListing(aStartingDir); if (sort) { Collections.sort(result); } return result; }
From source file:com.foilen.smalltools.upgrader.tasks.AbstractDatabaseUpgradeTask.java
protected List<String> mysqlTablesFindAll() { List<String> tableNames = jdbcTemplate.queryForList("SHOW TABLES", String.class); Collections.sort(tableNames); return tableNames; }
From source file:Main.java
/** * Auxilliary method required for merging two consecutive sorted lists in * place./*from w w w. jav a 2 s . co m*/ * * <p>This implementation is based on:</p> * * <p>J. Chen, "<a href="http://dx.doi.org/10.1016/j.ipl.2005.11.018">A * simple algorithm for in-place merging</a>", Information Processing * Letters 98:34-40, 2006.</p>. * * This method is a direct transcription of Fig. 5. */ private static <T extends Comparable<? super T>> void mergeBandY(List<T> A, int z, int y, int yn) { while (z < y && y <= yn) { int j = z + indexOfMin(A.subList(z, y)); if (A.get(j).compareTo(A.get(y)) <= 0) { Collections.swap(A, z, j); } else { Collections.swap(A, z, y); y++; } z++; } if (z < y) { Collections.sort(A.subList(z, yn + 1)); } }
From source file:com.amitshekhar.utils.PrefHelper.java
public static List<String> getSharedPreferenceTags(Context context) { ArrayList<String> tags = new ArrayList<>(); String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs"; File root = new File(rootPath); if (root.exists()) { for (File file : root.listFiles()) { String fileName = file.getName(); if (fileName.endsWith(PREFS_SUFFIX)) { tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length())); }/*from ww w. j a va 2 s . c o m*/ } } Collections.sort(tags); return tags; }
From source file:com.pseudosudostudios.jdd.utils.ScoreSaves.java
/** * @param c the application's context that owns the data file * @return a List of games saved in the file *///from w ww. jav a 2 s.co m public static List<Entry> getSaves(Context c) { List<Entry> entries = new ArrayList<Entry>(); File f = new File(c.getFilesDir(), fileName); if (!f.exists() || f.isDirectory()) { return new ArrayList<Entry>(); } try { BufferedReader reader = new BufferedReader(new FileReader(f)); StringBuffer buff = new StringBuffer(); while (reader.ready()) buff.append(reader.readLine()); reader.close(); JSONArray array = new JSONArray(buff.toString()); for (int i = 0; i < array.length(); i++) { Entry e = makeEntry(array.getJSONObject(i)); if (e.getScore() != IGNORE_SCORE) entries.add(e); } Collections.sort(entries); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return entries; }
From source file:it.cnr.isti.hpc.dexter.entity.EntityMatchList.java
public void sort() { Collections.sort(this); }
From source file:me.ardacraft.blocksapi.helper.LangHelper.java
public static void writeLangFile() { File out = FileHelper.externalConfigFile("assets/acblocks/lang", "en_US.lang"); try {/* ww w. jav a2s . c o m*/ FileWriter writer = new FileWriter(out); Collections.sort(entries); for (String s : entries) { writer.write(s); writer.append("\n"); } writer.close(); } catch (IOException e) { e.printStackTrace(); } entries.clear(); }
From source file:com.cronutils.model.time.TimeNode.java
public TimeNode(List<Integer> values) { this.values = Validate.notEmpty(values, "Values must not be empty"); Collections.sort(this.values); }
From source file:com.avatarproject.core.command.APTabCompleter.java
/** * Breaks down the possible list and returns what is applicable depending on * what the user has currently typed./* w w w . j a v a2s . c om*/ * * @author D4rKDeagle * * @param args Args of the command. Provide all of them. * @param possibilitiesOfCompletion List of things that can be given */ public static List<String> getPossibleCompletionsForGivenArgs(String[] args, List<String> possibilitiesOfCompletion) { String argumentToFindCompletionFor = args[args.length - 1]; List<String> listOfPossibleCompletions = new ArrayList<String>(); for (String foundString : possibilitiesOfCompletion) { if (foundString.regionMatches(true, 0, argumentToFindCompletionFor, 0, argumentToFindCompletionFor.length())) { listOfPossibleCompletions.add(foundString); } } Collections.sort(listOfPossibleCompletions); return listOfPossibleCompletions; }
From source file:net.groupbuy.service.impl.PluginServiceImpl.java
public List<PaymentPlugin> getPaymentPlugins() { Collections.sort(paymentPlugins); return paymentPlugins; }