[Vala] Sorting an ArrayList??

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

        return alternatives;


Navi Sidhu

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]