anchor.diff:  
     /// Applies a series of non-overlapping patches to the text of a file.
     static String applyAll(SourceFile file, List<Patch> patches) {
  -    var sortedPatches = patches.toList()
  -      ..sort((a, b) => a.selection.compareTo(b.selection));
  +    // We use mergeSort instead of List.sort here because [patches] can be
  +    // order-dependent when there are multiple insertion patches at the same
  +    // point, and List.sort is not guaranteed to be stable.
  +    var sortedPatches = patches.toList();
  +    mergeSort(sortedPatches);
  +
       var buffer = StringBuffer();
       int offset = 0;
       Patch lastPatch;
  
positive.code: // license that can be found in the LICENSE file or at
  // https://opensource.org/licenses/MIT.
  
  import 'package:source_span/source_span.dart';
  
  class Patch {
    /// Selection to be replaced
    final FileSpan selection;
  
  
negative.code:     buffer.write(file.getText(offset));
      return buffer.toString();
    }
  
    /// Patches are ordered based on their selection.
    int compareTo(Patch other) => selection.compareTo(other.selection);
  }
  