/** * Creates a sorted list that contains the items of the given iterable. The resulting list is sorted according to * the order induced by applying a key function to each element which yields a comparable criteria. * * @param iterable * the elements to be sorted. May not be <code>null</code>. * @param key * the key function to-be-used. May not be <code>null</code>. * @return a sorted list as a shallow copy of the given iterable. * @see #sort(Iterable) * @see #sort(Iterable, Comparator) * @see ListExtensions#sortInplaceBy(List, org.eclipse.xtext.xbase.lib.Functions.Function1) */ public static <T, C extends Comparable<? super C>> List<T> sortBy(Iterable<T> iterable, final Functions.Function1<? super T, C> key) { return ListExtensions.sortInplaceBy(Lists.newArrayList(iterable), key); }
/** * Creates a sorted list that contains the items of the given iterable. The resulting list is sorted according to * the order induced by applying a key function to each element which yields a comparable criteria. * * @param iterable * the elements to be sorted. May not be <code>null</code>. * @param key * the key function to-be-used. May not be <code>null</code>. * @return a sorted list as a shallow copy of the given iterable. * @see #sort(Iterable) * @see #sort(Iterable, Comparator) * @see ListExtensions#sortInplaceBy(List, org.eclipse.xtext.xbase.lib.Functions.Function1) */ public static <T, C extends Comparable<? super C>> List<T> sortBy(Iterable<T> iterable, final Functions.Function1<? super T, C> key) { return ListExtensions.sortInplaceBy(Lists.newArrayList(iterable), key); }
public void writeTokenFile(PrintWriter out) throws IOException { List<Map.Entry<Integer, String>> entries = Lists.newArrayList(getTokenDefMap().entrySet()); ListExtensions.sortInplaceBy(entries, new Functions.Function1<Map.Entry<Integer, String>, String>() { @Override public String apply(Map.Entry<Integer, String> p) { return p.getValue(); } }); for(Map.Entry<Integer, String> entry: entries) { out.print(entry.getValue()); out.print('='); out.println(entry.getKey()); } out.close(); }
List<GenPackage> packages = Lists.newArrayList(model.getGenPackages()); assertEquals(packageNames.length, packages.size()); ListExtensions.sortInplaceBy(packages, new Functions.Function1<GenPackage, String>() { @Override public String apply(GenPackage p) {
return _builder.toString(); }; ListExtensions.<StringConcatenationClient, String>sortInplaceBy(children_1, _function); StringConcatenationClient _client_2 = new StringConcatenationClient() { @Override