In the following code, how to return the alternatives arraylist, sorted
by name.
public Gee.ArrayList<string> getAdminDirectoryContents() {
// Create an empty arraylist
Gee.ArrayList<string> alternatives = new Gee.ArrayList<string>();
try {
// The directory from which to get contents
var directory = File.new_for_path (Constants.adminDirPath);
// Create an enumerator
var enumerator = directory.enumerate_children
(FILE_ATTRIBUTE_STANDARD_NAME, 0);
FileInfo file_info;
while ((file_info = enumerator.next_file ()) != null) {
alternatives.add(file_info.get_name ());
}
}
catch(Error e) {}
// I have tried this but array is not sorted
//alternatives.sort(Gee.Functions.get_compare_func_for(typeof(string)));
return alternatives;
}
Cheers,
Navi Sidhu
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list