Skip to content

Commit

Permalink
Flow.js : added flow notation for sort.js
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-redFox committed Aug 7, 2017
1 parent 4edd3c7 commit 36d842d
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,21 @@ module.exports = function sortDocs(comments: Array<Comment>, options: Object) {
return fixed.concat(unfixed);
};

function compare(a: string, b: string) {
return a.localeCompare(b, undefined, { caseFirst: 'upper' });
}

function compareCommentsByName(a, b) {
var akey = a.name;
var bkey = b.name;
function compareCommentsByName(a: Comment, b: Comment): number {
const akey: ?string = a.name;
const bkey: ?string = b.name;

if (akey && bkey) {
return compare(akey, bkey);
return akey.localeCompare(bkey, undefined, { caseFirst: 'upper' });
}
return 0;
}

function compareCommentsBySourceLocation(a, b) {
function compareCommentsBySourceLocation(a: Comment, b: Comment): number {
return a.context.sortKey.localeCompare(b.context.sortKey);
}

function sortComments(comments, sortOrder) {
function sortComments(comments: Array<Comment>, sortOrder: string) {
return comments.sort(
sortOrder === 'alpha'
? compareCommentsByName
Expand Down

0 comments on commit 36d842d

Please sign in to comment.