X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FMetaResultList.java;h=b5f3312282669624de6474dd7007e7a86c373080;hp=886defe8b1c6a9df42639f04c82ebd87d5396bbd;hb=58701825851d5533ec28b0ecd6c0c5ed645655c5;hpb=ef98466f666072746af72a45a40274110990f8bd diff --git a/src/be/nikiroo/fanfix/library/MetaResultList.java b/src/be/nikiroo/fanfix/library/MetaResultList.java index 886defe..b5f3312 100644 --- a/src/be/nikiroo/fanfix/library/MetaResultList.java +++ b/src/be/nikiroo/fanfix/library/MetaResultList.java @@ -3,6 +3,7 @@ package be.nikiroo.fanfix.library; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import be.nikiroo.fanfix.data.MetaData; @@ -39,8 +40,9 @@ public class MetaResultList { if (!sources.contains(meta.getSource())) sources.add(meta.getSource()); } + sort(sources); } - + return sources; } @@ -60,6 +62,7 @@ public class MetaResultList { } } + sort(linked); return linked; } @@ -70,8 +73,9 @@ public class MetaResultList { if (!authors.contains(meta.getAuthor())) authors.add(meta.getAuthor()); } + sort(authors); } - + return authors; } @@ -84,9 +88,10 @@ public class MetaResultList { tags.add(tag); } } + sort(tags); } - - return authors; + + return tags; } // helper @@ -99,10 +104,12 @@ public class MetaResultList { } // null or empty -> no check, rest = must be included - // source: a source ending in "/" means "this or any source starting with this", + // source: a source ending in "/" means "this or any source starting with + // this", // i;e., to enable source hierarchy // + sorted - public List filter(List sources, List authors, List tags) { + public List filter(List sources, List authors, + List tags) { if (sources != null && sources.isEmpty()) sources = null; if (authors != null && authors.isEmpty()) @@ -165,4 +172,19 @@ public class MetaResultList { Collections.sort(result); return result; } + + /** + * Sort the given {@link String} values, ignoring case. + * + * @param values + * the values to sort + */ + private void sort(List values) { + Collections.sort(values, new Comparator() { + @Override + public int compare(String o1, String o2) { + return ("" + o1).compareToIgnoreCase("" + o2); + } + }); + } }