[Vala] How can I sort an array of strings?



Hi,

I need to sort an array of strings in natural order but the solutions I
found didn't worked for me. I tried this:

    /* Method to fill the array files */
    protected void get_files() {
        string file = "";
        do {
            file = dir.read_name();
            this.files += file;
        } while(file != null);

        /* Cut "null" which was only needed to terminate the loop */
        this.files.resize(files.length-1);
        this.files.sort(strcmp);
    }

'dir' is an opened directory and files is an array of strings (private
static string[] files). I get this message: 'error: The name `sort' does
not exist in the context of `string[]' this.files.sort(strcmp);'

Does anyone know what goes wrong?


Regards,

Karsten



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