Alıntı:
>> import std.stdio, std.array;
>
> class ass_arr
> {
> int[string] table;
> string defaultKey;
>
> this() { }
>
> @property
> auto setValue(int num)
> {
> table[defaultKey] = num;
> }
>
> @property
> auto shadowTable()
> {
> return table;
> }
> }
>
> void main()
> {
> with(new ass_arr())
> {
> foreach(value; 0..10) {
> defaultKey = replicate(".", value);
> setValue(value);
> }
>
> int i;
> foreach(key, value; shadowTable) {
> write(i++,"->");
> writeln(key, value);
> }
> }
> }
> ```
> **Çıktısı:**
> '0->0
> 1->..2
> 2->....4
> 3->......6
> 4->........8
> 5->.1
> 6->...3
> 7->.....5
> 8->.......7
> 9->.........9
> '
>
İlginç bir sıralama tekniği var. Sanırım Ali hocam yetkin cevap verecektir...:)
--
[ Bu gönderi, <http://ddili.org/forum>'dan dönüştürülmüştür. ]