Sort mapped reduced comments. Module comments first followed by class, variables and methods.
@param {Comment[]} comments an array of mapped-reduced comments
@return {Comment[]} sorted comments array
@private
964941
function sortComments(comments) {
    var moduleComments = [];
    var typeComments = [];
    var varComments = [];
    var methodComments = [];
    var typelessComments = [];

    comments.forEach(function (comment) {
        if(comment.type) {
            switch(comment.type) {
                case exports.COMMENT_TYPES.MODULE:
                    moduleComments.push(comment);
                    break;
                case exports.COMMENT_TYPES.METHOD:
                    methodComments.push(comment);
                    break;
                case exports.COMMENT_TYPES.TYPE:
                    typeComments.push(comment);
                    break;
                case exports.COMMENT_TYPES.VARIABLE:
                    varComments.push(comment);
                    break;
            }
        } else {
            typelessComments.push(comment);
        }
    });

    return moduleComments.concat(typeComments.concat(varComments.concat(methodComments.concat(typelessComments))));
}
68750
function analyseComment(comment, callback) {
  var reg = /(@(require|async|require\.async)\s+)('[^']+'|"[^"]+"|[^\s;!@#%^&*()]+)/g;
  callback = callback || function(m, prefix, type, value) {
    type = type === 'require' ? type : 'async';

    return prefix + map[type].wrap(value);
  };

  return comment.replace(reg, callback).replace(/(?:@|#)\s+sourceMappingURL=([^\s]+)/g, function(_, value) {
    return '# sourceMappingURL=' + map.sourceMap.wrap(value);
  });
}
149229
def store_comments   #:nodoc:
    return if @comments.array.empty?

    spid = @object_ids.spid
    num_comments    = comments_size

    # Number of objects written so far.
    num_objects     = images_size + @filter_area.count + charts_size

    @comments.array.each_index { |i| spid = @comments.array[i].store_comment_record(i, num_objects, num_comments, spid) }

    # Write the NOTE records after MSODRAWIING records.
    @comments.array.each_index { |i| @comments.array[i].store_note_record(num_objects + i + 1) }
  end
12000
function addComment(start, end, type, value) {
        assert(typeof start === 'number', 'Comment must have valid position');

        // Because the way the actual token is scanned, often the comments
        // (if any) are skipped twice during the lexical analysis.
        // Thus, we need to skip adding a comment if the comment array already
        // handled it.
        if (extra.comments.length > 0) {
            if (extra.comments[extra.comments.length - 1].range[1] > start) {
                return;
            }
        }

        extra.comments.push({
            range: [start, end],
            type: type,
            value: value
        });
    }
635492
function emitTrailingCommentsOfPosition(pos) {
                if (compilerOptions.removeComments) {
                    return;
                }
                var trailingComments = ts.getTrailingCommentRanges(currentText, pos);
                // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
                ts.emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
            }
24802
function removeComments(line) {
	var commentStartIndex = line.indexOf('#');
	if (commentStartIndex > -1) {
		return line.substr(0, commentStartIndex);
	}

	return line;
}
370825
public function serializeComments(array $comments, array $options = [])
    {
        foreach ($comments as $comment) {
            $comments[] = $this->serialize($comment);
        }

        return $comments;
    }
811644
function removeDuplicateComments(ast) {
    // Some comments are duplicated as both the leadingComment for one node,
    // and the trailing comment for another. Every comment's range is unique,
    // so two comments with the same range are talking about the same comment.
    // So we'll just remove all trailing comments which are also a leading
    // comment somewhere.
    //eslint-disable-next-line no-undef
    const rangesInLeadingComments = new Set();
    estreeWalker.walk(ast, {
        enter: (node) => {
            for (let leadingComment of node.leadingComments || []) {
                rangesInLeadingComments.add(leadingComment.range.join(','));
            }
        }
    });
    estreeWalker.walk(ast, {
        enter: (node) => {
            if (!node.trailingComments) {
                return;
            }
            node.trailingComments = node.trailingComments.filter((comment) => {
                return !rangesInLeadingComments.has(comment.range.join(','));
            });
        }
    });
}
186381
function formatComment(comment) {
  if (!comment) {
    return undefined;
  }
  const parts = comment.trim().split('\n');
  if (parts.length === 1 && parts[0].indexOf('*') !== 0) {
    return parts[0];
  }
  return parts.reduce((previousValue, currentValue) => {
    // newlines in the middle of the comment should stay to achieve:
    // multiline comments entered by user drive unchanged from JDL
    // studio to generated domain class
    let delimiter = '';
    if (previousValue !== '') {
      delimiter = '\n';
    }
    return previousValue.concat(delimiter, currentValue.trim().replace(/[*]*\s*/, ''));
  }, '');
}
681332
function findJSDocComment(comments, line) {

    if (comments) {
        for (var i = comments.length - 1; i >= 0; i--) {
            if (comments[i].type === "Block" && comments[i].value.charAt(0) === "*") {

                if (line - comments[i].loc.end.line <= 1) {
                    return comments[i];
                }
                break;
            }
        }
    }

    return null;
}
41947
function remove_comments(){
      if (options.clean_comments) {
        html = html.replace(/<!--[\s\S]*?-->/g, function(str){
          if (str.match(/<!--\[if /)) { return str; }
          if (str.match(/\n/)) { return str; }
          else { return ""; }
        });
      }
    }
584707
function() {
    var allTags = [];
    
    for (var key in this.posts) {
      if (this.posts[key].tags) {
        for (var i = 0; i < this.posts[key].tags.length; i++) {
          var tag = this.posts[key].tags[i];
          if (allTags.indexOf(tag) === -1) allTags.push(tag);
        }
      }
    }

    allTags.sort(function(a, b) {
      a = a.toLowerCase();
      b = b.toLowerCase();
      if (a < b) return -1;
      if (a > b) return 1;
      return 0;
    });

    return allTags;
  }
609019
function comment(editor, range, modelType) {
	const commentParts = modelComments[modelType];
	editor.setTextInBufferRange(new Range(range.end, range.end), ` ${commentParts.after}`);
	editor.setTextInBufferRange(new Range(range.start, range.start), `${commentParts.before} `);
}
974283
function commentsExistBetween(left, right) {
            return sourceCode.getFirstTokenBetween(
                left,
                right,
                {
                    includeComments: true,
                    filter: astUtils.isCommentToken
                }
            ) !== null;
        }
731658
public function setComments($comments)
    {
        $this->comments = [];
        if (!is_array($comments)) {
            $comments = [$comments];
        }
        foreach ($comments as $comment) {
            $this->addComment($comment);
        }

        return $this;
    }
147109
function findLeadingComments(comments, index, beginIndex, first) {
    const leadComments = [];
    if (first && ignoreComment.test(comments[index].raw)) {
        return leadComments;
    }
    let backIndex = index - 1;
    while (backIndex >= beginIndex &&
        (comments[backIndex].loc.end.line + 1 === comments[backIndex + 1].loc.start.line
            || comments[backIndex].loc.end.line === comments[backIndex + 1].loc.start.line)) {
        if (first && ignoreComment.test(comments[backIndex].raw)) {
            break;
        }
        backIndex -= 1;
    }
    for (let ind = backIndex + 1; ind <= index; ind += 1) {
        leadComments.push(comments[ind]);
    }
    return leadComments;
}
255917
function createCommentDiv(comment) {
    if (!comment.displayed && !opts.moderator) {
      return $('<div class="moderate">Thank you!  Your comment will show up '
               + 'once it is has been approved by a moderator.</div>');
    }
    // Prettify the comment rating.
    comment.pretty_rating = comment.rating + ' point' +
      (comment.rating == 1 ? '' : 's');
    // Make a class (for displaying not yet moderated comments differently)
    comment.css_class = comment.displayed ? '' : ' moderate';
    // Create a div for this comment.
    var context = $.extend({}, opts, comment);
    var div = $(renderTemplate(commentTemplate, context));

    // If the user has voted on this comment, highlight the correct arrow.
    if (comment.vote) {
      var direction = (comment.vote == 1) ? 'u' : 'd';
      div.find('#' + direction + 'v' + comment.id).hide();
      div.find('#' + direction + 'u' + comment.id).show();
    }

    if (opts.moderator || comment.text != '[deleted]') {
      div.find('a.reply').show();
      if (comment.proposal_diff)
        div.find('#sp' + comment.id).show();
      if (opts.moderator && !comment.displayed)
        div.find('#cm' + comment.id).show();
      if (opts.moderator || (opts.username == comment.username))
        div.find('#dc' + comment.id).show();
    }
    return div;
  }