Re: [Vala] How can I sort an array of strings?
- From: Fabian Deutsch <fabian deutsch gmx de>
- To: "K." König <kkoenig posteo de>
- Cc: vala-list gnome org
- Subject: Re: [Vala] How can I sort an array of strings?
- Date: Thu, 21 Apr 2011 14:34:34 +0200
Good day Karsten,
Am Donnerstag, den 21.04.2011, 14:22 +0200 schrieb K. König:
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?
Built-in arrays do not provide the .sort function. Try to use Gee.Lists.
- fabian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]