GN: Makes GN output deterministic

Sorts various output just prior to printing to ensure that GN output
is deterministic.

The overall effect on performance is relatively small, with
runtime over 50 runs varying as follows on my Z840:

    +-------+-------+-------+
    |       |  old  |  new  |
    +-------+-------+-------+
    | mean  | 1415  | 1430  |
    +-------+-------+-------+
    | stdev | 58.0  | 70.5  |
    +-------+-------+-------+

To verify results:
$ gn gen out/Default; mv out out-1
$ gn gen out/Default; mv out out-2
$ diff -qr out-1 out-2

The diff should be empty.

Initial discussion can be seen at https://groups.google.com/a/chromium.org/forum/#!topic/gn-dev/8mOLgM4r3PI.

BUG=565075

Review URL: https://codereview.chromium.org/1494883002

Cr-Original-Commit-Position: refs/heads/master@{#364954}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 98ec25a8fb3f710d43d60b1bcdc5a1475aab136f
3 files changed
tree: 5e7f19c6c4ffefa33260e59874e2a96c1d6d158b
  1. tools/