message: lexicographical compare for ordering of complex objects automagically
diff: @@ -352,3 +352,32 @@ export type ProgressHandle = vscode.Progress<ProgressReport>;
  export class DummyDisposable {
  dispose() {}
  }
  +
  +export function lexicographicalCompare(a: Iterable<string>, b: Iterable<string>): number {
  + const a_iter = a[Symbol.iterator]();
  + const b_iter = a[Symbol.iterator]();
  + while (1) {
  + const a_res = a_iter.next();
  + const b_res = b_iter.next();
  + if (a_res.done) {
  + if (b_res.done) {
  + return 0; // Same elements
  + } else {
  + // a is "less" (shorter string)
  + return -1;
  + }
  + } else if (b_res.done) {
  + // b is "less" (shorter)
  + return 1;
  + } else {
  + const comp_res = a_res.value.localeCompare(b_res.value);
  + if (comp_res !== 0) {
  + return comp_res;
  + }
  + }
  + }
  + // Loop analysis can't help us. TS believes we run off the end of
  + // the function.
  + console.assert(false, 'Impossible code path');
  + return 0;
  +}
  \ No newline at end of file
  