Commit f77700e6 authored by Jim Nelson's avatar Jim Nelson

#1953: Sorting files using UTF8 collating.

parent e9037eb1
......@@ -5,6 +5,7 @@ Matthias Clasen <matthias.clasen@gmail.com>
David Jeske <davidj@gmail.com>
Matt Jones <mattjones@workhorsy.org>
Andreas Kühntopf <andreas@kuehntopf.org>
Rafael Monica <monraaf@gmail.com>
Paul Novak <pnovak@alumni.caltech.edu>
Martin Robinson <martin.james.robinson@gmail.com>
Shan Xiong <shan.xiong@gmail.com>
......
......@@ -6,8 +6,20 @@
public delegate int64 Comparator(void *a, void *b);
extern string g_utf8_collate_key_for_filename(string str, ssize_t len = -1);
public int64 file_comparator(void *a, void *b) {
return strcmp(((File *) a)->get_path(), ((File *) b)->get_path());
string? path_a = ((File *) a)->get_path();
string? path_b = ((File *) b)->get_path();
// if both are null, treat as equal; if one but not the other, prioritize the non-null
if (path_a == null)
return (path_b == null) ? 0 : 1;
if (path_b == null)
return -1;
return strcmp(g_utf8_collate_key_for_filename(path_a), g_utf8_collate_key_for_filename(path_b));
}
public class SortedList<G> : Object, Gee.Iterable<G>, Gee.Collection<G> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment