Index: sdk/lib/_internal/pub/lib/src/lock_file.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/lock_file.dart b/sdk/lib/_internal/pub/lib/src/lock_file.dart |
index 2f391613dbe4c396e5196a91e814d32cd30bae14..1e85a4d0e37f080c2bae62b9d59ccccc66dc06f1 100644 |
--- a/sdk/lib/_internal/pub/lib/src/lock_file.dart |
+++ b/sdk/lib/_internal/pub/lib/src/lock_file.dart |
@@ -5,6 +5,7 @@ |
library lock_file; |
import 'dart:json' as json; |
+import 'dart:collection'; |
import 'package:yaml/yaml.dart'; |
@@ -88,12 +89,16 @@ class LockFile { |
/// Returns the serialized YAML text of the lock file. |
String serialize() { |
- var packagesObj = <String, Map>{}; |
- packages.forEach((name, id) { |
+ var packagesObj = new LinkedHashMap<String, Map>(); |
+ |
+ // Sort the packages by name. |
+ var sortedKeys = packages.keys.toList(); |
+ sortedKeys.sort(); |
+ sortedKeys.forEach((name) { |
packagesObj[name] = { |
- 'version': id.version.toString(), |
- 'source': id.source.name, |
- 'description': id.description |
+ 'version': packages[name].version.toString(), |
+ 'source': packages[name].source.name, |
+ 'description': packages[name].description |
}; |
}); |