[WebAssembly] Use stable sort when sorting ctore functions

Patch by Nicholas Wilson!

llvm-svn: 325656
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index ffb987e..6ffce92 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -871,10 +871,10 @@
   }
   // Sort in order of priority (lowest first) so that they are called
   // in the correct order.
-  std::sort(InitFunctions.begin(), InitFunctions.end(),
-            [](const WasmInitFunc &L, const WasmInitFunc &R) {
-              return L.Priority < R.Priority;
-            });
+  std::stable_sort(InitFunctions.begin(), InitFunctions.end(),
+                   [](const WasmInitFunc &L, const WasmInitFunc &R) {
+                     return L.Priority < R.Priority;
+                   });
 }
 
 void Writer::run() {