Created attachment 530
Test case
Hello,
the order of the items seems inconsistent depending on key type.
Please see the attachment.
Thank you,
Julian.
Comment #1 by andrei — 2009-12-22T06:56:19Z
This is by design - associative arrays don't come out in key sorted order. We could change that behavior but that would make the function slower.
Comment #2 by julien — 2009-12-22T07:29:04Z
Created attachment 531
Quick hack
Would this quick hack make the function slower too ? Tested with a few unittests. It removes the segfaults from anytype[ushort] too.
Comment #3 by julien — 2009-12-22T07:30:52Z
Created attachment 532
Quick hack (const s.length)
Small correction.
Comment #4 by julien — 2009-12-22T07:32:53Z
Created attachment 533
if (i > 0) result.put(separator);
Comment #5 by andrei — 2009-12-22T08:02:56Z
(In reply to comment #4)
> Created an attachment (id=533) [details]
> if (i > 0) result.put(separator);
The code assumes the set of numeric keys is contiguous, which is untrue for most associative arrays. For example, trying the code with [5:"a", 100:"b"] will fail.
Comment #6 by julien — 2009-12-22T08:16:07Z
Right. Back to slow indexes sorting.
Thank you,
Julian.