From: Niki Roo Date: Sat, 18 Apr 2020 15:19:31 +0000 (+0200) Subject: Merge branch 'master' into subtree X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=commitdiff_plain;h=148f02268b892f6df74ddd86b4b1703b74ac8da8;hp=-c Merge branch 'master' into subtree --- 148f02268b892f6df74ddd86b4b1703b74ac8da8 diff --combined data/MetaData.java index 2c40beb,586196a..586196a --- a/data/MetaData.java +++ b/data/MetaData.java @@@ -390,12 -390,14 +390,14 @@@ public class MetaData implements Clonea return 1; } - String id = (getUuid() == null ? "" : getUuid()) + String id = (getTitle() == null ? "" : getTitle()) + + (getUuid() == null ? "" : getUuid()) + (getLuid() == null ? "" : getLuid()); - String oId = (getUuid() == null ? "" : o.getUuid()) + String oId = (getTitle() == null ? "" : o.getTitle()) + + (getUuid() == null ? "" : o.getUuid()) + (o.getLuid() == null ? "" : o.getLuid()); - return id.compareTo(oId); + return id.compareToIgnoreCase(oId); } @Override diff --combined library/MetaResultList.java index 886defe,b5f3312..b5f3312 --- a/library/MetaResultList.java +++ b/library/MetaResultList.java @@@ -3,6 -3,7 +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 +40,9 @@@ public class MetaResultList if (!sources.contains(meta.getSource())) sources.add(meta.getSource()); } + sort(sources); } - + return sources; } @@@ -60,6 -62,7 +62,7 @@@ } } + sort(linked); return linked; } @@@ -70,8 -73,9 +73,9 @@@ if (!authors.contains(meta.getAuthor())) authors.add(meta.getAuthor()); } + sort(authors); } - + return authors; } @@@ -84,9 -88,10 +88,10 @@@ tags.add(tag); } } + sort(tags); } - - return authors; + + return tags; } // helper @@@ -99,10 -104,12 +104,12 @@@ } // 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 +172,19 @@@ 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); + } + }); + } }