Re: foreach for string[string]AA

2017-03-02 Thread Mike Wey via Digitalmars-d-learn
On 03/02/2017 09:09 AM, Anton Pastukhov wrote: On Wednesday, 1 March 2017 at 19:26:23 UTC, Mike Wey wrote: On 02/28/2017 07:16 PM, Anton Pastukhov wrote: On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote: [...] Thank you for the link, it was informative reading. It's a pity

Re: foreach for string[string]AA

2017-03-02 Thread Anton Pastukhov via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 19:26:23 UTC, Mike Wey wrote: On 02/28/2017 07:16 PM, Anton Pastukhov wrote: On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote: [...] Thank you for the link, it was informative reading. It's a pity that still there is no ordered AA at least as a

Re: foreach for string[string]AA

2017-03-01 Thread Mike Wey via Digitalmars-d-learn
On 02/28/2017 07:16 PM, Anton Pastukhov wrote: On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote: V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: I can't see the logic in AA foreach order. Consider this

Re: foreach for string[string]AA

2017-03-01 Thread Minty Fresh via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 18:16:45 UTC, Anton Pastukhov wrote: On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote: V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: I can't see the logic in AA foreach

Re: foreach for string[string]AA

2017-02-28 Thread Anton Pastukhov via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote: V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: I can't see the logic in AA foreach order. Consider this code: ... Output: three two one four I was sure

Re: foreach for string[string]AA

2017-02-28 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 28 Feb 2017 15:15:00 + Anton Pastukhov via Digitalmars-d-learn napsáno: > I can't see the logic in AA foreach order. Consider this code: > ... > Output: > three > two > one > four > > I was sure output should be > one > two > three > four

Re: foreach for string[string]AA

2017-02-28 Thread Anton Pastukhov via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 15:44:46 UTC, bachmeier wrote: On Tuesday, 28 February 2017 at 15:33:46 UTC, ikod wrote: AA implemented as hash table, so it doesn't preserve insertion order. You have to sort keys when you need: import std.algorithm; import std.stdio; void main() {

Re: foreach for string[string]AA

2017-02-28 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 15:33:46 UTC, ikod wrote: AA implemented as hash table, so it doesn't preserve insertion order. You have to sort keys when you need: import std.algorithm; import std.stdio; void main() { auto aa = ["one":1, "two":2

Re: foreach for string[string]AA

2017-02-28 Thread ikod via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 15:15:00 UTC, Anton Pastukhov wrote: I can't see the logic in AA foreach order. Consider this code: ``` void main() { string[string] test = [ "one": "1", "two": "2", "three": "3", "four": "4" ]; import

foreach for string[string]AA

2017-02-28 Thread Anton Pastukhov via Digitalmars-d-learn
I can't see the logic in AA foreach order. Consider this code: ``` void main() { string[string] test = [ "one": "1", "two": "2", "three": "3", "four": "4" ]; import std.stdio:writeln; foreach(k, v; test) { writeln(k); } } Output: