This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coser. See https://gitlab.nuiton.org/codelutin/coser.git commit cf39e615acca0a580ca16f73758195a989fac49b Author: Eric Chatellier <chatellier@codelutin.com> Date: Thu Mar 2 11:04:32 2017 +0100 fixes #9087: Tri des listes par ordre alphabetique --- .../ifremer/coser/result/CoserRequestExecutor.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java index 5611a15..bc1194e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java @@ -39,6 +39,10 @@ import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -281,7 +285,22 @@ public class CoserRequestExecutor { for (MapResult map : mapResults) { resultAsMap.putAll(map.getResult()); } - return resultAsMap; + return sortByValue(resultAsMap); + } + + protected static <K, V extends Comparable<? super V>> Map<K, V> sortByValue( Map<K, V> map ) { + List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>( map.entrySet() ); + Collections.sort( list, new Comparator<Map.Entry<K, V>>() { + public int compare( Map.Entry<K, V> o1, Map.Entry<K, V> o2 ) { + return (o1.getValue()).compareTo( o2.getValue() ); + } + } ); + + Map<K, V> result = new LinkedHashMap<K, V>(); + for (Map.Entry<K, V> entry : list) { + result.put( entry.getKey(), entry.getValue() ); + } + return result; } public List<ResultRepository> getMatchingRepositories() { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.