Re: multiSort for sorting AA by value

2015-04-21 Thread bearophile via Digitalmars-d-learn
Chris: I'm happy with it, but maybe there is a more concise implementation? This is a bit shorter and a bit better (writefln is not yet able to format tuples nicely): void main() { import std.stdio: writeln; import std.algorithm.sorting: multiSort; import std.array: array;

Re: multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
Maybe something like bearophile's example should go into the documentation of std.algorithm.sorting.multiSort. It's a common enough thing in programming.

Re: multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 11:46:24 UTC, bearophile wrote: Chris: I'm happy with it, but maybe there is a more concise implementation? This is a bit shorter and a bit better (writefln is not yet able to format tuples nicely): void main() { import std.stdio: writeln; import

multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
The following works great. It sorts an AA by value: 1. by frequency of word 2. by alphabetic order (if two or more words have the same value) import std.stdio : writefln; import std.algorithm.sorting : multiSort; void main() { size_t[string] wcount = [ hamster:5, zorro:80,